제출 #1208886

#제출 시각아이디문제언어결과실행 시간메모리
1208886andrejikus선물상자 (IOI15_boxes)C++20
50 / 100
2093 ms4524 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; void DBG() { cerr << "]" << endl; } template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); } #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) static char _buffer[1024]; static int _currentChar = 0; static int _charsNumber = 0; static FILE *_inputFile, *_outputFile; const int N = 1003; const ll inf = 1e18; static inline int _read() { if (_charsNumber < 0) { exit(1); } if (!_charsNumber || _currentChar == _charsNumber) { _charsNumber = (int)fread(_buffer, sizeof(_buffer[0]), sizeof(_buffer), _inputFile); _currentChar = 0; } if (_charsNumber <= 0) { return -1; } return _buffer[_currentChar++]; } static inline int _readInt() { int c, x, s; c = _read(); while (c <= 32) c = _read(); x = 0; s = 1; if (c == '-') { s = -1; c = _read(); } while (c > 32) { x *= 10; x += c - '0'; c = _read(); } if (s < 0) x = -x; return x; } long long delivery(int n, int k, int l, int p[]) { ll ans = inf; for (int i = 0; i <= n; i++) { ll res = 0; int r = (n-i); int ost1 = i%k; if (i > k && p[i-1-k] > l/2) continue; for (int j = (ost1 == 0 ? k-1 : ost1-1); j < i; j += k) { if (j==i-1) res += p[j]; if (j==i-1) res += min(p[j], l-p[j]); else res += 2*p[j]; } int ost2 = r%k; if (r > k && p[n-r+k] < l/2) continue; for (int j = (ost2 == 0 ? k-1 : ost2-1); j < r; j += k) { if (j == r-1) res += (l-p[n-1-j]); if (j==r-1) res += min(l-p[n-1-j], p[n-1-j]); else res += 2*(l-p[n-1-j]); } ans = min(ans, res); } 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...