제출 #711173

#제출 시각아이디문제언어결과실행 시간메모리
711173Nhoksocqt1선물상자 (IOI15_boxes)C++17
10 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define sz(x) int((x).size()) #define fi first #define se second typedef long long ll; typedef pair<int, int> ii; template<class X, class Y> inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);} template<class X, class Y> inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);} mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int Random(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); } const int MAXN = 1e7+7; int a[MAXN], nArr, k, L; #ifdef Nhoksocqt1 int delivery(int _N, int _K, int _L, int _pos[]); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); freopen("BOXES.inp", "r", stdin); freopen("BOXES.out", "w", stdout); process(); return 0; } #endif // Nhoksocqt1 ll delivery(int _N, int _K, int _L, int _pos[]) { nArr = _N, k = _K, L = _L; for (int i = 1; i <= nArr; ++i) a[i] = _pos[i - 1]; sort(a + 1, a + nArr + 1); ll result(0); int l(1), r(nArr); while(l <= r) { int costLeft = min(_L, 2 * a[min(r, l + _K - 1)]); int costRight = min(_L, 2 * (_L - a[max(l, r - _K + 1)])); result += min(costLeft, costRight); if(costLeft <= costRight) { l += _K; } else { r -= _K; } } return result; }
#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...