Submission #974199

# Submission time Handle Problem Language Result Execution time Memory
974199 2024-05-03T05:55:16 Z sleepntsheep Akcija (COCI15_akcija) C
80 / 80
8 ms 860 KB
#include<stdio.h>
#define N 100000

int n, a[N+1], b[N], o;
long long z;

int main()
{
    scanf("%d",&n);
    for(int x,i=0;i<n;++i)scanf("%d",&x),++a[x];
    for(int i=1;i<=100000;++i)while(a[i])--a[i],b[o++]=i;
    while(o>=3)z+=b[o-1]+b[o-2],o-=3;
    if(o>=2)z+=b[1];
    if(o>=1)z+=b[0];
    printf("%lld\n",z);
}

Compilation message

akcija.c: In function 'main':
akcija.c:9:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ^~~~~~~~~~~~~~
akcija.c:10:27: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for(int x,i=0;i<n;++i)scanf("%d",&x),++a[x];
      |                           ^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 7 ms 856 KB Output is correct
7 Correct 7 ms 676 KB Output is correct
8 Correct 7 ms 676 KB Output is correct
9 Correct 8 ms 860 KB Output is correct
10 Correct 8 ms 856 KB Output is correct