Submission #727899

#TimeUsernameProblemLanguageResultExecution timeMemory
727899Boycl07Boxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms340 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; #define rep(i, n) for(int i = 1; i <= n; ++i) #define forn(i, l, r) for(int i = l; i <= r; ++i) #define ford(i, r, l) for(int i = r; i >= l; --i) #define fi first #define se second #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define endl "\n" #define C(x, y) make_pair(x, y) template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; } template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; } const int MN = 1e7 + 7; const int MOD = 1e9 + 7 ; const int INF = 1e13 + 9999; const int block_size = 230; const int LIM = 2e7; const int p = 1e12; ll pre[MN], suf[MN]; long long delivery(int N, int K, int L, int p[]) { ll res = 1e18; rep(i, N) { pre[i] = pre[max(0, i - K)] + p[i - 1] + min(p[i - 1], L - p[i - 1]); } ford(i, N, 1) { suf[i] = suf[min(N + 1, i + K)] + L - p[i - 1] + min(p[i - 1], L - p[i - 1]); } rep(i, N) minimize(res, pre[i] + suf[i + 1]); return res; }

Compilation message (stderr)

boxes.cpp:23:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0000000009999e+13' to '2147483647' [-Woverflow]
   23 | const int INF = 1e13 + 9999;
      |                 ~~~~~^~~~~~
boxes.cpp:26:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+12' to '2147483647' [-Woverflow]
   26 | const int p = 1e12;
      |               ^~~~
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:31:45: warning: declaration of 'p' shadows a global declaration [-Wshadow]
   31 | long long delivery(int N, int K, int L, int p[])
      |                                         ~~~~^~~
boxes.cpp:26:11: note: shadowed declaration is here
   26 | const int p = 1e12;
      |           ^
#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...