Submission #673730

#TimeUsernameProblemLanguageResultExecution timeMemory
673730Hacv16Boxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; const int INF = 5e18 + 15;; typedef long long ll; ll getDist(ll x, ll y, ll l){ if(y > x) swap(x, y); return min(x - y, l - x + y); } ll delivery(int n, int k, int l, int p[]){ if(k == 1){ ll ans = 0; for(int i = 0; i < n; i++) ans += 2 * getDist(0, p[i], l); return ans; } ll mx = p[n - 1], mn = p[0], ans = INF; ans = min(ans, getDist(0, mx, l) + getDist(mx, mn, l) + getDist(mn, 0, l)); ans = min(ans, getDist(0, mn, l) + getDist(mn, mx, l) + getDist(mx, 0, l)); return ans; }

Compilation message (stderr)

boxes.cpp:4:22: warning: overflow in conversion from 'double' to 'int' changes value from '5.0e+18' to '2147483647' [-Woverflow]
    4 | const int INF = 5e18 + 15;;
      |                 ~~~~~^~~~
#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...