# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
163008 | 2019-11-10T19:52:26 Z | kostia244 | 선물상자 (IOI15_boxes) | C++14 | 2 ms | 376 KB |
#include "boxes.h" #include<bits/stdc++.h> #define pb push_back #define all(x) x.begin(), x.end() using namespace std; using ll = long long; using vi = vector<ll>; ll n, k, l; vi pos, dpl, dpr; ll getl(ll x) { return min(2ll*x, l); } ll getr(ll x) { return min(2ll*(l-x), l); } long long delivery(int N, int K, int L, int P[]) { n=N, k = K, l = L; ll ans = LLONG_MAX; pos.resize(n+2); dpl.resize(n+2); dpr.resize(n+2); for(int i = 0; i < n; i++) pos[i+1] = P[i]; for(int i = 1; i <= n; i++) { if(i%k==1) { dpl[i] = dpl[i-1]+getl(pos[i]); } else { dpl[i] = dpl[i-1]-getl(pos[i-1])+getl(pos[i]); } } for(int i = n; i; i--) { if((n-i)%k==0) { dpr[i] = dpr[i+1]+getr(pos[i]); } else { dpr[i] = dpr[i+1]-getr(pos[i+1])+getr(pos[i]); } } for(int i = 0; i <= n; i++) { ans = min(ans, dpl[i]+dpr[i+1]); // cout << i << " " << dpl[i] << " " << dpr[i+1] << "\n"; } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Incorrect | 2 ms | 256 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |