Submission #933816

#TimeUsernameProblemLanguageResultExecution timeMemory
933816raul2008487Boxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "boxes.h" #define ll int #define in insert #define pb push_back #define vl vector<ll> #define fi first #define se second #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const ll inf = 1000000000000000000; long long delivery(int N, int K, int L, int p[]) { ll n = N, k = K, ans, i, j; vl dpp(n), dps(n); for(i = 0; i < n; i++){ if(i >= k){ dpp[i] = dpp[i - k] + min(p[i] * 2, L); } else{ dpp[i] = min(p[i] * 2, L); } //dpp[i] = dpp[pr] + p[i - 1] + min(L - p[i - 1], p[i - 1]); } for(i = n; i > 0; i--){ if((i + k) < n){ dps[i] = dps[i + k] + min(L, 2 * (L - p[i])); } else{ dps[i] = min(L, 2 * (L - p[i])); } //dps[i] = dps[nxt] + (L - p[i - 1]) + min(L - p[i - 1], p[i - 1]); } ans = min(dps[0], dpp[n - 1]); for(i = 0; i < n - 1; i++){ ans = min(ans, (dpp[i] + dps[i + 1])); } return ans; }

Compilation message (stderr)

boxes.cpp:12:16: warning: overflow in conversion from 'long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   12 | const ll inf = 1000000000000000000;
      |                ^~~~~~~~~~~~~~~~~~~
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:14:30: warning: unused variable 'j' [-Wunused-variable]
   14 |     ll n = N, k = K, ans, i, j;
      |                              ^
#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...