Submission #897638

#TimeUsernameProblemLanguageResultExecution timeMemory
897638oblantisBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms348 KiB
#include "boxes.h" #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define all(v) v.begin(), v.end() #define pb push_back #define ss second #define ff first #define vt vector using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, int> pdi; const ll inf = 1e18 + 10000; const int mod = 1e9+7; const int maxn = 1e5 + 12; long long delivery(int n, int k, int l, int p[]) { deque<int> ls, mr; int cnt = 0; for(int i = 0; i < n; i++){ if(n % 2 == 0 && p[i] == n / 2)cnt++; else if(p[i] <= l / 2)ls.pb(p[i]); else mr.pb(p[i]); } if(ls.size() >= mr.size())while(cnt--)ls.pb(n / 2); else while(cnt--)mr.push_front(n / 2); ll ret = 0; while(int(ls.size()) >= k){ int x = ls.back(); for(int i = 0; i < k; i++){ ls.pop_back(); } ret += x * 2; } while(int(mr.size()) >= k){ int x = mr.front(); for(int i = 0; i < k; i++){ mr.pop_front(); } ret += (l - x) * 2; } if(mr.empty() && ls.empty())return ret; else if(mr.empty() && !ls.empty())ret += ls.back() * 2; else if(!mr.empty() && ls.empty())ret += (l - mr.front()) * 2; else if(int(mr.size() + ls.size()) > k)ret += ls.back() * 2 + (l - mr.front()) * 2; else ret += min(l, ls.back() * 2 + (l - mr.front()) * 2); return ret; } //int main(){ //return 0; //}
#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...