# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151741 | 2019-09-04T13:39:54 Z | arnold518 | None (KOI17_cook) | C++14 | 5 ms | 2808 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 3000; int N, M, S, E, T, A[MAXN+10][MAXN+10], B[MAXN+10]; int dp[MAXN+10][MAXN+10], ans=2147483647; deque<pii> DQ[MAXN+10]; int main() { int i, j; scanf("%d%d%d%d%d", &N, &M, &S, &E, &T); for(i=1; i<=N; i++) for(j=1; j<=M; j++) scanf("%d", &A[i][j]); for(i=1; i<=N; i++) for(j=M; j>=0; j--) A[i][j]+=A[i][j+1]; for(i=1; i<=N; i++) scanf("%d", &B[i]); for(i=2; i<=S; i++) for(j=1; j<=N; j++) dp[j][i]=987654321; for(i=S+1; i<=M+1; i++) { vector<pii> V; for(j=1; j<=N; j++) { while(!DQ[j].empty() && DQ[j].front().second<i-E) DQ[j].pop_front(); while(!DQ[j].empty() && DQ[j].back().first>=A[j][i-S]+dp[j][i-S]) DQ[j].pop_back(); DQ[j].push_back({dp[j][i-S]+A[j][i-S], i-S}); V.push_back({DQ[j].front().first-A[j][i], j}); } sort(V.begin(), V.end()); for(j=1; j<=N; j++) { for(auto it : V) { if(i!=M+1 && (it.second==j || it.second==B[j])) continue; dp[j][i]=it.first+T; break; } } } for(j=1; j<=N; j++) ans=min(ans, dp[j][M+1]-T); printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2808 KB | Output is correct |
2 | Incorrect | 5 ms | 2808 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2808 KB | Output is correct |
2 | Incorrect | 5 ms | 2808 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2808 KB | Output is correct |
2 | Incorrect | 5 ms | 2808 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2808 KB | Output is correct |
2 | Incorrect | 5 ms | 2808 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2808 KB | Output is correct |
2 | Incorrect | 5 ms | 2808 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |