Submission #137445

#TimeUsernameProblemLanguageResultExecution timeMemory
137445claudyBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
161 ms156924 KiB
# include "boxes.h" # pragma GCC optimize("Ofast,no-stack-protector") # pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") # pragma GCC optimize("Ofast") # pragma GCC optimization ("unroll-loops") # include "bits/stdc++.h" /* # include <ext/pb_ds/tree_policy.hpp> # include <ext/pb_ds/assoc_container.hpp> # include <ext/rope> */ std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}}; # define ll long long # define clock (clock() * 1000.0 / CLOCKS_PER_SEC) # define rc(s) return cout << s,0 # define rcg(s) cout << s;exit(0) # define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); # define db(x) cerr << #x << " = " << x << '\n' # define pb push_back # define mp make_pair # define all(s) s.begin(),s.end() # define sz(x) (int)((x).size()) # define int ll using namespace std; int a[10000005]; int ans1[10000005],ans2[10000005]; int ans; void f(int &s,int val) { cout << val << '\n'; s = min(s,val); } #undef int ll delivery(int n, int k, int L, int p[]) { #define int ll vector<int>vec; for(int i = 0;i < n;i++) vec.pb(p[i]); sort(vec.begin(),vec.end()); memset(ans1,0,sizeof(ans1)); memset(ans2,0,sizeof(ans2)); for(int i = 0;i < sz(vec);i++) { ans1[i] = (2ll * vec[i]) + (i >= k ? ans1[i - k] : 0); } for(int i = sz(vec) - 1;i >= 0;i--) { ans2[i] = (2ll * (L - vec[i])) + (i + k < sz(vec) ? ans2[i + k] : 0); } ans = 1e18; f(ans,ans2[0]); for(int i = 0;i < k;i++) a[i] = 1e18; a[0] = 0; for(int i = 0;i < sz(vec);i++) { f(ans,ans1[i] + ans2[i + 1]); } for(int i = k;i <= n;i++) { f(ans, ans2[i] + a[i % k] + (i / k) * L); a[i % k] = min(a[i % k],ans1[i - 1] - (i / k) * L); } //cout << ans << '\n'; return ans; }

Compilation message (stderr)

boxes.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 # pragma GCC optimization ("unroll-loops")
#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...