Submission #1091029

#TimeUsernameProblemLanguageResultExecution timeMemory
1091029hengliaoBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
413 ms137364 KiB
#include "boxes.h" #include <bits/stdc++.h> #include <random> #include <chrono> using namespace std; #define F first #define S second #define pb push_back #define vll vector<ll> #define pll pair<ll, ll> typedef long long ll; const ll inf=1e18; ll delivery(int n, int k, int l, int p[]) { auto get=[&](ll a, ll b){ if(b<a) return 0LL; ll re=l; re=min(re, 2LL*p[b]); re=min(re, 2LL*(l-p[a])); return re; }; ll ans=inf; for(ll s=0;s<k;s++){ ll cur=get(0, s-1); ll pre; for(ll i=s;i<n;i+=k){ cur+=get(i, min(i+k-1, (ll)n-1)); } ans=min(ans, cur); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:29:12: warning: unused variable 'pre' [-Wunused-variable]
   29 |         ll pre;
      |            ^~~
#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...