Submission #666292

#TimeUsernameProblemLanguageResultExecution timeMemory
666292jamezzzBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define LINF 1023456789123456789 typedef long long ll; #define maxn 10000005 ll pfx[maxn], sfx[maxn]; ll delivery(int N, int K, int L, int p[]){ sort(p, p + N); for (int i = 0; i < N; ++i) { if (2 * p[i] > L) { sfx[i % K] += (L - p[i]) * 2; } else { sfx[i % K] += L; } } ll ans = LINF; for (int i = 0; i < N; ++i) { if (2 * p[i] < L) { pfx[i % K] += p[i] * 2; sfx[i % K] -= L; } else { pfx[i % K] += L; sfx[i % K] -= (L - p[i]) * 2; } ans = min(ans, pfx[i % K] + sfx[(i + 1) % K]); } return ans; } int main(){ int N, K, L, p[maxn]; scanf("%d%d%d", &N, &K, &L); for(int i = 0; i < N; ++i){ scanf("%d", &p[i]); } printf("%lld\n", delivery(N, K, L, p)); }

Compilation message (stderr)

boxes.cpp: In function 'int main()':
boxes.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d%d%d", &N, &K, &L);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         scanf("%d", &p[i]);
      |         ~~~~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccTOPrJ4.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/ccL2wHC4.o:boxes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status