답안 #145989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145989 2019-08-21T13:52:12 Z grobar Akcija (COCI15_akcija) C++14
80 / 80
60 ms 760 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int mod=n%3;
    int sum=0;
    for(int i=(n-1);i>0;i=i-3)
    {
        sum=sum+a[i]+a[i-1];
        //cout<<sum<<" "<<a[i]<<" "<<a[i-1]<<endl;
    }
    if(mod==1)
    {
        sum=sum+a[0];
    }
    cout<<sum<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 44 ms 760 KB Output is correct
7 Correct 40 ms 760 KB Output is correct
8 Correct 40 ms 632 KB Output is correct
9 Correct 60 ms 672 KB Output is correct
10 Correct 58 ms 632 KB Output is correct