Submission #996515

#TimeUsernameProblemLanguageResultExecution timeMemory
996515AlfraganusBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
7 ms600 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; #define ll long long ll delivery(int n, int k, int l, int p[]) { sort(p, p + n); ll ans = 1e18; auto get = [&](ll x){return min(x, l - x);}; vector<int> q; for(int i = 0; i < n; i ++) if(p[i] != 0) q.push_back(p[i]); n = (int)q.size(); // for(int i = 0; i < (1 << n); i ++){ // // cout << i << endl; // ll mx = 0; // deque<int> dq; // for(int j = 0; j < n; j ++){ // if(i & (1 << j)){ // dq.push_back(q[j]); // } // } // // for(auto x : dq) // // cout << x << ' '; // // cout << endl; // while(dq.size() > 0){ // int sz = (int)dq.size(); // ll clock = dq.back() + get(dq.back()); // mx += clock; // for(int j = 0; j < min(sz, k); j ++) // dq.pop_back(); // } // for(int j = 0; j < n; j ++){ // if((i & (1 << j)) == 0){ // dq.push_back(q[j]); // } // } // // for(auto x : dq) // // cout << x << ' '; // // cout << endl; // while(dq.size() > 0){ // int sz = (int)dq.size(); // ll clock = l - dq.front() + get(dq.front()); // mx += clock; // for(int j = 0; j < min(sz, k); j ++) // dq.pop_front(); // } // // cout << mx << endl; // ans = min(ans, mx); // } // return ans; for(int i = 0; i <= n; i ++){ deque<int> dq; for(int j = 0; j < i; j ++) dq.push_back(q[j]); // for(auto x : dq) // cout << x << ' '; // cout << endl; ll mx = 0; while(dq.size() > 0){ int sz = (int)dq.size(); ll clock = dq.back() + dq.back(); mx += clock; for(int j = 0; j < min(sz, k); j ++) dq.pop_back(); } for(int j = i; j < n; j ++) dq.push_back(q[j]); while(dq.size() > 0){ int sz = (int)dq.size(); ll counterclock = l - dq.front() + l - dq.front(); mx += counterclock; for(int j = 0; j < min(sz, k); j ++) dq.pop_front(); } // cout << i << ' ' << mx << endl; ans = min(ans, mx); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:10:10: warning: variable 'get' set but not used [-Wunused-but-set-variable]
   10 |     auto get = [&](ll x){return min(x, l - x);};
      |          ^~~
#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...