Submission #1201520

#TimeUsernameProblemLanguageResultExecution timeMemory
1201520cleversquidBoxes with souvenirs (IOI15_boxes)C++20
0 / 100
0 ms328 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; int delivery(int N, int K, int L, int v[]){ //N is the number of teams that need their gifts //K is the carrying capacity //L is the number of nodes (ex. L = 8 gives us: 0,1,2,3,4,5,6,7) //v[] is an array vector<int> team_pos(v, v+N); sort(team_pos.begin(), team_pos.end()); vector<int> cw(N+5, -1); vector<int> ccw(N+5, -1); cw[0] = 0; ccw[0] = 0; //clock wise building for(int i = 1; i<= N; i++){ if(i <= K){ cw[i] = 2*team_pos[i-1]; } else{ if(i%K == 0){ cw[i] = 2*team_pos[i-1]; } else{ cw[i] = cw[i - i%K] + 2*team_pos[i-1]; } } //cout << "cw[" << i << "] = " << cw[i] << "\n"; } sort(team_pos.begin(), team_pos.end(), greater<int>()); //counterclockwise building for(int i = 1; i<= N; i++){ if(i <= K){ ccw[i] = 2* (L - team_pos[i-1]); } else{ if(i%K == 0){ ccw[i] = 2*(L - team_pos[i-1]); } else{ ccw[i] = ccw[i - i%K] + 2*(L - team_pos[i-1]); } } //cout << "ccw[" << i << "] = " << ccw[i] << "\n"; } //sort(team_pos.begin(), team_pos.end()); int no_full = 1e9 + 1; int yes_full = 1e9+1; for(int i = 1; i<=N; i++){ no_full = min(no_full, cw[i] + ccw[N-i]); yes_full = min(yes_full, cw[i] + L + ccw[N-K-i]); } //cout << no_full << " " << yes_full << "\n"; //cout << min(no_full, yes_full) << "\n"; return min(no_full, yes_full); }
#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...