제출 #140085

#제출 시각아이디문제언어결과실행 시간메모리
140085SirCeness선물상자 (IOI15_boxes)C++14
0 / 100
2 ms376 KiB
#include "boxes.h" #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define inside sl<=l&&r<=sr #define outside r<sl||sr<l #define orta ((l+r)>>1) #define INF 1000000009 #define mod 1000000007 #define ppair(x); cerr << "(" << x.first << ", " << x.second << ")\n"; #define bas(x) #x << ": " << x << " " #define prarr(x, n); cerr << #x << ": "; for(int qsd = 0; qsd < n; qsd++) cerr << x[qsd] << " "; cerr << "\n"; #define prarrv(x); cerr << #x << ": "; for(int qsd = 0; qsd < (int)x.size(); qsd++) cerr << x[qsd] << " "; cerr << "\n"; using namespace std; typedef long long ll; int n, k, s; vector<int> arr; ll delivery(int N, int K, int L, int p[]) { n = N; k = K; s = L; for (int i = 0; i < n; i++) arr.pb(p[i]); sort(arr.begin(), arr.end()); int artik = n%k; int l = 0; int r = n-1; ll bas = arr[l+artik-1]; ll son = s - arr[r-artik+1]; ll ans = 0; if (bas < son){ ans = bas*2; l += artik; } else { ans = son*2; r -= artik; } while (l < r){ bas = arr[l+k-1]; son = s-arr[r-k+1]; if (2*bas > s && 2*son > s){ ans += s; l += k; continue; } if (bas < son) ans += bas*2, l += k; else ans += son*2, r -= k; } 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...