답안 #87804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87804 2018-12-02T15:32:02 Z asifthegreat Akcija (COCI15_akcija) C++14
80 / 80
26 ms 3344 KB
#include <bits/stdc++.h>
using namespace std;

int ara[300000];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n;i++){
        scanf("%d",&ara[i]);
    }
    sort(ara+1,ara+1+n,greater<int>());
    int sum = 0;
    int last_taken = -1;
    ara[n+1] = 0;
    ara[n+2] = 0;
    for(int i = 1; i <= n;i+=3){
        sum += ara[i];
        sum += ara[i+1];
    }
    printf("%d\n",sum);
    return 0;
}

Compilation message

akcija.cpp: In function 'int main()':
akcija.cpp:15:9: warning: unused variable 'last_taken' [-Wunused-variable]
     int last_taken = -1;
         ^~~~~~~~~~
akcija.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
akcija.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&ara[i]);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 400 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 20 ms 1400 KB Output is correct
7 Correct 15 ms 1796 KB Output is correct
8 Correct 14 ms 2204 KB Output is correct
9 Correct 25 ms 2852 KB Output is correct
10 Correct 26 ms 3344 KB Output is correct