Submission #153861

#TimeUsernameProblemLanguageResultExecution timeMemory
153861AlexPascu007Akcija (COCI15_akcija)C++98
80 / 80
66 ms1220 KiB
#include <iostream> #include <algorithm> using namespace std; long long n,i,c[100010],s; int main() { cin>>n; for (i=1;i<=n;i++) cin>>c[i]; sort(c+1,c+n+1); for (i=n;i>=1;i--) { s+=c[i]; if (n%3==0) { if (i%3==1) s-=c[i]; } else if (n%3==1) { if (i%3==2) s-=c[i]; } else if (n%3==2) { if (i%3==0) s-=c[i]; } } cout<<s; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...