# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153901 | 2019-09-17T11:25:14 Z | arnold518 | None (JOI14_ho_t2) | C++14 | 90 ms | 20240 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXM = 1e4; const int MAXN = 500; const int INF = 1e8; int M, N, P[MAXM+10], C[MAXN+10], E[MAXN+10]; int dp[MAXN+10][MAXM+10], ans; int main() { int i, j; scanf("%d%d", &M, &N); for(i=1; i<=M; i++) scanf("%d", &P[i]); sort(P+1, P+M+1, greater<int>()); for(i=1; i<=M; i++) P[i]+=P[i-1]; for(i=1; i<=N; i++) scanf("%d%d", &C[i], &E[i]); for(i=1; i<=M; i++) dp[0][i]=INF; for(i=1; i<=N; i++) { deque<int> DQ; for(j=1; j<=M; j++) { while(!DQ.empty() && DQ.front()<j-C[i]) DQ.pop_front(); while(!DQ.empty() && dp[i-1][DQ.back()]>=dp[i-1][j-1]) DQ.pop_back(); DQ.push_back(j-1); dp[i][j]=min(dp[i-1][DQ.front()]+E[i], dp[i-1][j]); } } for(i=1; i<=M; i++) ans=max(ans, P[i]-dp[N][i]); printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 888 KB | Output is correct |
4 | Correct | 4 ms | 888 KB | Output is correct |
5 | Correct | 6 ms | 760 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 380 KB | Output is correct |
9 | Correct | 6 ms | 888 KB | Output is correct |
10 | Correct | 7 ms | 888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 20088 KB | Output is correct |
2 | Correct | 57 ms | 20088 KB | Output is correct |
3 | Correct | 59 ms | 20052 KB | Output is correct |
4 | Correct | 60 ms | 20060 KB | Output is correct |
5 | Correct | 59 ms | 20028 KB | Output is correct |
6 | Correct | 9 ms | 4344 KB | Output is correct |
7 | Correct | 50 ms | 16120 KB | Output is correct |
8 | Correct | 58 ms | 19980 KB | Output is correct |
9 | Correct | 10 ms | 4344 KB | Output is correct |
10 | Correct | 54 ms | 19992 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 888 KB | Output is correct |
4 | Correct | 4 ms | 888 KB | Output is correct |
5 | Correct | 6 ms | 760 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 380 KB | Output is correct |
9 | Correct | 6 ms | 888 KB | Output is correct |
10 | Correct | 7 ms | 888 KB | Output is correct |
11 | Correct | 56 ms | 20088 KB | Output is correct |
12 | Correct | 57 ms | 20088 KB | Output is correct |
13 | Correct | 59 ms | 20052 KB | Output is correct |
14 | Correct | 60 ms | 20060 KB | Output is correct |
15 | Correct | 59 ms | 20028 KB | Output is correct |
16 | Correct | 9 ms | 4344 KB | Output is correct |
17 | Correct | 50 ms | 16120 KB | Output is correct |
18 | Correct | 58 ms | 19980 KB | Output is correct |
19 | Correct | 10 ms | 4344 KB | Output is correct |
20 | Correct | 54 ms | 19992 KB | Output is correct |
21 | Correct | 54 ms | 20088 KB | Output is correct |
22 | Correct | 69 ms | 19960 KB | Output is correct |
23 | Correct | 73 ms | 20008 KB | Output is correct |
24 | Correct | 66 ms | 20124 KB | Output is correct |
25 | Correct | 71 ms | 20088 KB | Output is correct |
26 | Correct | 71 ms | 19952 KB | Output is correct |
27 | Correct | 20 ms | 6264 KB | Output is correct |
28 | Correct | 90 ms | 20240 KB | Output is correct |
29 | Correct | 75 ms | 20056 KB | Output is correct |
30 | Correct | 82 ms | 19708 KB | Output is correct |