Submission #137409

#TimeUsernameProblemLanguageResultExecution timeMemory
137409claudyBoxes with souvenirs (IOI15_boxes)C++14
50 / 100
2027 ms38220 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 ans1[1 << 20],ans2[1 << 20]; 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 < sz(vec);i++) { f(ans,ans1[i] + ans2[i + 1]); } for(int i = 0;i < sz(vec);i++) { for(int j = i + k - 1;j < sz(vec);j += k) { f(ans,(i ? ans1[i - 1] : 0) + ((j - i + 1) / k) * L + ans2[j + 1]); } } //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...