제출 #1294578

#제출 시각아이디문제언어결과실행 시간메모리
1294578ghammazhassanBoxes with souvenirs (IOI15_boxes)C++20
0 / 100
1 ms652 KiB
#include "boxes.h" #include <iostream> #include <cmath> #include <algorithm> #include <map> #include <unordered_map> #include <vector> #include <iomanip> #include <string> #include <queue> #include <set> #include <deque> using namespace std; // static char _buffer[1024]; // static int _currentChar = 0; // static int _charsNumber = 0; // static FILE *_inputFile, *_outputFile; // 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; // } int n,k,l; long long delivery(int N,int K,int L, int b[]){ n=N,k=K,l=L; k=min(k,n); vector<int>a1,a2; a1.push_back(0); a2.push_back(0); for (int i=0;i<n;i++){ if (b[i]<=l/2){ a1.push_back(b[i]); } else{ a2.push_back(l-b[i]); } } int n1=a1.size(),n2=a2.size(); vector<int>pr1(n1),pr2(n2); for (int i=1;i<n1;i++){ pr1[i]=a1[i]; if (i>=k){ pr1[i]+=pr1[i-k]; } } for (int i=1;i<n2;i++){ pr2[i]=a2[i]; if (i>=k){ pr2[i]+=pr2[i-k]; } } int c=pr1[n1-1]+pr2[n2-1]; for (int i=1;i<k;i++){ if (i>=n1)break; if (k-i>=n2)continue; c=min(c,l+pr1[n1-i-1]+pr2[n2-(k-i)-1]); } return c*2; } // int main() { // _inputFile = fopen("input.txt", "rb"); // _outputFile = fopen("output.txt", "w"); // int N, K, L, i; // N = _readInt(); // K = _readInt(); // L = _readInt(); // int *p = (int*)malloc(sizeof(int) * (unsigned int)N); // for (i = 0; i < N; i++) { // p[i] = _readInt(); // } // fprintf(_outputFile, "%lld\n", delivery(N, K, L, p)); // 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...