# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
464329 | 2021-08-13T02:49:12 Z | sumit_kk10 | 선물상자 (IOI15_boxes) | C++14 | 16 ms | 15988 KB |
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) #define ll long long int #define ld long double using namespace std; const int MOD = 1e9 + 7; long long delivery(int N, int K, int L, int positions[]){ int n = N, k = K, l = L; sort(positions + 1, positions + n + 1); long long pre_dp[n + 2][k + 1], suf_dp[n + 2][k + 1]; for(int j = 1; j <= k; ++j) pre_dp[1][j] = 2*positions[1]; for(int i = 2; i <= n; ++i){ for(int j = 1; j <= k; ++j){ pre_dp[i][j] = INT_MAX; if(j == 1) pre_dp[i][j] = min(pre_dp[i][j], pre_dp[i - 1][k] + 2*positions[i]); else pre_dp[i][j] = min(pre_dp[i][j], pre_dp[i - 1][j - 1] + 2*(positions[i] - positions[i - 1])); } } for(int i = 1; i <= n; ++i){ ll x = l - positions[i]; positions[i] = x; } for(int j = 1; j <= k; ++j){ suf_dp[n][j] = 2*positions[n]; suf_dp[n + 1][j] = 0; pre_dp[0][j] = 0; } for(int i = n - 1; i >= 1; --i){ for(int j = 1; j <= k; ++j){ suf_dp[i][j] = INT_MAX; if(j == 1) suf_dp[i][j] = min(suf_dp[i][j], suf_dp[i + 1][k] + 2*positions[i]); else suf_dp[i][j] = min(suf_dp[i][j], suf_dp[i + 1][j - 1] + 2*(positions[i] - positions[i + 1])); } } ll ans = INT_MAX; for(int i = 1; i <= n; ++i){ ll mn = INT_MAX; for(int j = 1; j <= k; ++j) mn = min(mn, suf_dp[i + 1][j]); for(int j = 1; j <= k; ++j) ans = min(ans, pre_dp[i][j] + mn); } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 15988 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |