답안 #153861

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
153861 2019-09-17T05:15:41 Z AlexPascu007 Akcija (COCI15_akcija) C++
80 / 80
66 ms 1220 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 44 ms 1220 KB Output is correct
7 Correct 40 ms 1144 KB Output is correct
8 Correct 40 ms 1132 KB Output is correct
9 Correct 66 ms 1144 KB Output is correct
10 Correct 59 ms 1144 KB Output is correct