# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
319575 | 2020-11-05T14:24:28 Z | tjdgus4384 | 선물상자 (IOI15_boxes) | C++14 | 1 ms | 512 KB |
#include<bits/stdc++.h> #include "boxes.h" using namespace std; long long delivery(int N, int K, int L, int positions[]){ int i; long long ans = 0; if(K == 1 || K == N){ for(i = 0;i + K - 1 < N;i += K){ if(positions[i] > L/2) ans += (long long)(L-positions[i])*2; else if(positions[i + K - 1] <= L/2) ans += (long long)positions[i + K - 1]*2; else{ for(int j = i+1;j <= i + K - 1;j++){ if(positions[j]-positions[j-1] > L/2){ ans += (long long)(L-positions[j]+positions[j-1])*2; goto next; } } ans += (long long)L; } next:; } if(i == N) return ans; if(positions[i] > L/2) ans += (long long)(L-positions[i])*2; else if(positions[N-1] <= L/2) ans += (long long)positions[N-1] * 2; else{ for(int j = i+1;j <= N - 1;j++){ if(positions[j]-positions[j-1] > L/2){ ans += (long long)(L-positions[j]+positions[j-1])*2; goto next1; } } ans += (long long)L; } next1:; return ans; } for(int i = 1;i < N;i++){ if(positions[i] - positions[i-1] > L/2){ int t = i - 1; while(t >= 0) {ans += positions[t]*2;t -= K;} t = i; while(t < N) {ans += (L-positions[t])*2;t += K;} return ans; } } long long ans1 = 0, ans2 = 0; for(i = 0;i + K - 1 < N;i += K){ if(positions[i] > L/2) ans1 += (long long)(L-positions[i])*2; else if(positions[i + K - 1] <= L/2) ans1 += (long long)positions[i + K - 1]*2; else ans1 += (long long)L; } if(i != N){ if(positions[i] > L/2) ans1 += (long long)(L-positions[i])*2; else if(positions[N-1] <= L/2) ans1 += (long long)positions[N-1] * 2; else ans1 += (long long) L; } for(i = 0;i + K - 1 < N;i += K){ if(positions[N - 1 - i] > L/2) ans2 += (long long)(L-positions[N - 1 - i])*2; else if(positions[N - 1 - (i + K - 1)] <= L/2) ans2 += (long long)positions[N - 1 - (i + K - 1)]*2; else ans2 += (long long)L; } if(i != N){ if(positions[N - 1 - i] > L/2) ans2 += (long long)(L-positions[N - 1 - i])*2; else if(positions[0] <= L/2) ans2 += (long long)positions[0] * 2; else ans2 += (long long) L; } return min(ans1, ans2); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 372 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 372 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 512 KB | Output is correct |
15 | Incorrect | 1 ms | 512 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 372 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 512 KB | Output is correct |
15 | Incorrect | 1 ms | 512 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 372 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 512 KB | Output is correct |
15 | Incorrect | 1 ms | 512 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |