[์ฝ๋ํฌ์ค] 1463B - Find The Array (Educational Codeforces Round 100 (Rated for Div. 2)
2020. 12. 22. 18:56ใ๐จ๐ป๐ซ ํ๋ก๊ทธ๋๋ฐ/Codeforces
2020.12.22 ์ฝ๋ํฌ์ค ์์ด๋ ์์ฑ!
์๊ณ ๋ฆฌ์ฆ ๊ณต๋ถํ๋ฉฐ ๋ฐฑ์ค๋ง ์กฐ๊ธ์ฉ ํ๋ค๊ฐ ๋ด ์์น๊ฐ ์ด๋๊ฐ ๊ถ๊ธํด์ ๋์ ํ๊ฒ ๋ฌ์ต๋๋ค.
์ง์ฆ์ ์ข ๊พธ์คํ ์๊ณ ๋ฆฌ์ฆ ๊ณต๋ถํ ๊ฑธ... ์กธ์ ํ๊ณ ๊ณต๋ถํ๋ ๋ ๋ฐ์ฑํฉ์๋ค ใ ใ ...
21๋ ์๋ ๋ธ๋ฃจ ๋ฌ์๋ณด๊ณ ์ทจ๋ฝํ์!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=51;
int t,n;
ll oddSum,evenSum,a[MAX],b[MAX];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>t;
while(t--){
cin>>n;
evenSum=0;
oddSum=0;
for(int i=1;i<=n;i++){
cin>>a[i];
if(i%2) oddSum+=a[i];
else evenSum+=a[i];
}
fill(b,b+n+1,1);
int sp=1;
if(oddSum<evenSum) sp=2;
for(int i=sp;i<=n;i+=2){
b[i]=a[i];
}
for(int i=1;i<=n;i++) cout<<b[i]<<" ";
cout<<"\n";
}
return 0;
}