Submission #785275

#TimeUsernameProblemLanguageResultExecution timeMemory
785275acatmeowmeowBoxes with souvenirs (IOI15_boxes)C++11
100 / 100
498 ms293644 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; const int N = 1e7; long long prefix[N + 5], suffix[N + 5]; long long delivery(int N, int K, int L, int p[]) { for (int i = 0; i < N; i++) prefix[i] = (i - K >= 0 ? prefix[i - K] : 0ll) + (long long)p[i] + (long long)min(p[i], L - p[i]); for (int i = N - 1; i >= 0; i--) suffix[i] = (i + K < N ? suffix[i + K] : 0ll) + (long long)L - p[i] + (long long)min(p[i], L - p[i]); long long ans = min(prefix[N - 1], suffix[0]); for (int i = 0; i + 1 < N; i++) ans = min(ans, prefix[i] + suffix[i + 1]); return ans; } /*int main() { int n, k, l; cin >> n >> k >> l; int p[n]; for (int i = 0; i < n; i++) cin >> p[i]; long long ans = delivery(n, k, l, p); cout << ans << '\n'; return 0; }*/

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:9:24: warning: declaration of 'N' shadows a global declaration [-Wshadow]
    9 | long long delivery(int N, int K, int L, int p[]) {
      |                    ~~~~^
boxes.cpp:6:11: note: shadowed declaration is here
    6 | const int N = 1e7;
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...