[์ฝ”๋“œํฌ์Šค] 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;
}