Submission #137827

# Submission time Handle Problem Language Result Execution time Memory
137827 2019-07-28T10:12:29 Z ioilolcom Candies (JOI18_candies) C++14
0 / 100
3 ms 504 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
vector<ll> one,two;
const int N=2e5+6;
ll on[N];
ll off[N];
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;

	for(int i=1; i<=n; i++) {
		int a; cin>>a;
		if(i&1) {
			one.push_back(a);
		}
		else{
			two.push_back(a);
		}
	}
	sort(one.rbegin(),one.rend());
	sort(two.rbegin(),two.rend());
	on[0]=one[0];
	int a=(int)one.size();
	int b=(int)two.size();
	for(int i=1; i<(int)one.size(); i++) {
		on[i]=on[i-1]+one[i];
	}
	off[0]=two[0];
	for(int i=1; i<(int)two.size(); i++) {
		off[i]=off[i-1]+two[i];
	}
	for(int i=1; i<=(n/2+(n%2)); i++) {
		ll mx1=0;
		ll mx2=0;
		if(i<=a) {
			mx1=on[i-1];
		}
		if(i<=b) {
			mx2=off[i-1];
		}
		ll ans=max(mx1,mx2);
		cout<<ans<<endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -