Submission #55130

# Submission time Handle Problem Language Result Execution time Memory
55130 2018-07-06T05:49:07 Z 윤교준(#1528) None (JOI14_ho_t2) C++11
100 / 100
24 ms 1896 KB
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[sz(V)-2])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmax(a,b) (a)=max((a),(b))
#define upmin(a,b) (a)=min((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;

const int MAXN = 10005;
const int MAXK = 505;

int dp[MAXN*2];

int A[MAXN];
int B[MAXK], C[MAXK];

int N, K, Ans;

int main() {
    //freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(false);

	cin >> N >> K;
	for(int i = 1; i <= N; i++) cin >> A[i];
	for(int i = 1; i <= K; i++) cin >> B[i] >> C[i];

	sort(A+1, A+N+1);
	reverse(A+1, A+N+1);
	for(int i = 1; i <= N; i++) A[i] += A[i-1];

	fill(dp, dp+MAXN*2, INF); dp[0] = 0;
	for(int i = 1; i <= K; i++) {
        upmin(B[i], N);
		for(int j = MAXN*2-B[i]-1; 0 <= j; j--)
			upmin(dp[j+B[i]], dp[j] + C[i]);
	}

	for(int i = 1; i <= N; i++)
		upmax(Ans, A[i] - dp[i]);
    for(int i = N+1; i < MAXN*2; i++)
        upmax(Ans, A[N] - dp[i]);

	cout << Ans << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 544 KB Output is correct
3 Correct 5 ms 544 KB Output is correct
4 Correct 4 ms 592 KB Output is correct
5 Correct 5 ms 712 KB Output is correct
6 Correct 2 ms 728 KB Output is correct
7 Correct 3 ms 728 KB Output is correct
8 Correct 4 ms 728 KB Output is correct
9 Correct 5 ms 864 KB Output is correct
10 Correct 5 ms 1160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1160 KB Output is correct
2 Correct 18 ms 1160 KB Output is correct
3 Correct 24 ms 1160 KB Output is correct
4 Correct 14 ms 1160 KB Output is correct
5 Correct 14 ms 1176 KB Output is correct
6 Correct 15 ms 1180 KB Output is correct
7 Correct 16 ms 1252 KB Output is correct
8 Correct 20 ms 1284 KB Output is correct
9 Correct 14 ms 1284 KB Output is correct
10 Correct 20 ms 1336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 544 KB Output is correct
3 Correct 5 ms 544 KB Output is correct
4 Correct 4 ms 592 KB Output is correct
5 Correct 5 ms 712 KB Output is correct
6 Correct 2 ms 728 KB Output is correct
7 Correct 3 ms 728 KB Output is correct
8 Correct 4 ms 728 KB Output is correct
9 Correct 5 ms 864 KB Output is correct
10 Correct 5 ms 1160 KB Output is correct
11 Correct 15 ms 1160 KB Output is correct
12 Correct 18 ms 1160 KB Output is correct
13 Correct 24 ms 1160 KB Output is correct
14 Correct 14 ms 1160 KB Output is correct
15 Correct 14 ms 1176 KB Output is correct
16 Correct 15 ms 1180 KB Output is correct
17 Correct 16 ms 1252 KB Output is correct
18 Correct 20 ms 1284 KB Output is correct
19 Correct 14 ms 1284 KB Output is correct
20 Correct 20 ms 1336 KB Output is correct
21 Correct 8 ms 1392 KB Output is correct
22 Correct 11 ms 1432 KB Output is correct
23 Correct 11 ms 1460 KB Output is correct
24 Correct 14 ms 1524 KB Output is correct
25 Correct 15 ms 1584 KB Output is correct
26 Correct 11 ms 1704 KB Output is correct
27 Correct 14 ms 1736 KB Output is correct
28 Correct 14 ms 1896 KB Output is correct
29 Correct 14 ms 1896 KB Output is correct
30 Correct 14 ms 1896 KB Output is correct