Submission #685094

#TimeUsernameProblemLanguageResultExecution timeMemory
685094viciousBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms336 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define si second typedef pair<int,int> pi; typedef tuple<int,int,int> ti; template<typename T> bool chmin(T &a, T b){return (b < a) ? a = b, 1 : 0;} template<typename T> bool chmax(T &a, T b){return (b > a) ? a = b, 1 : 0;} void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) int n,k,l,a[10000010]; vector<pi> pos; ll pref,suff,cnt,ans; long long delivery(int N, int K, int L, int p[]) { n=N,k=K,l=L; for (int i = 0; i < n; ++i) a[i+1]=p[i]; int lx=0,rx=n+1; while (lx<rx-1) { if (a[lx+1]<l-a[rx-1]+1) { pos.push_back({a[++lx],0}); } else { pos.push_back({a[--rx],1}); } } reverse(pos.begin(),pos.end()); suff=l+1; for (auto i: pos) { if (i.si==0) { pref=i.fi; } else { suff=i.fi; } ++cnt; if (cnt==k) { if (pref+l-suff+1<=l/2) ans += 2*(pref+l-suff+1); else ans += l; cnt=0; pref=0; suff=l+1; } } if (cnt) { if (pref+l-suff+1<=l/2) ans += 2*(pref+l-suff+1); else ans += l; } return ans; }
#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...