Submission #448251

# Submission time Handle Problem Language Result Execution time Memory
448251 2021-07-29T12:37:55 Z JovanB None (JOI14_ho_t2) C++17
100 / 100
16 ms 492 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int INF = 1e9;
 
int dp[20005];
int a[10005];
 
int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;
 
	int n, m;
	cin >> n >> m;
	for(int i=1; i<=n; i++){
        cin >> a[i];
	}
	sort(a+1, a+1+n);
	reverse(a+1, a+1+n);
	for(int i=1; i<=2e4; i++) dp[i] = INF;
	for(int i=1; i<=m; i++){
        int x, y;
        cin >> x >> y;
        for(int j=2e4; j>=x; j--){
            dp[j] = min(dp[j], y + dp[j-x]);
        }
	}
	for(int j=2e4-1; j>=1; j--){
        dp[j] = min(dp[j], dp[j+1]);
	}
	int res = 0;
	int sum = 0;
	for(int i=1; i<=n; i++){
        sum += a[i];
        res = max(res, sum - dp[i]);
	}
	cout << res << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 2 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 460 KB Output is correct
2 Correct 11 ms 492 KB Output is correct
3 Correct 12 ms 460 KB Output is correct
4 Correct 11 ms 468 KB Output is correct
5 Correct 13 ms 332 KB Output is correct
6 Correct 11 ms 404 KB Output is correct
7 Correct 12 ms 464 KB Output is correct
8 Correct 11 ms 460 KB Output is correct
9 Correct 10 ms 332 KB Output is correct
10 Correct 12 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 2 ms 456 KB Output is correct
11 Correct 12 ms 460 KB Output is correct
12 Correct 11 ms 492 KB Output is correct
13 Correct 12 ms 460 KB Output is correct
14 Correct 11 ms 468 KB Output is correct
15 Correct 13 ms 332 KB Output is correct
16 Correct 11 ms 404 KB Output is correct
17 Correct 12 ms 464 KB Output is correct
18 Correct 11 ms 460 KB Output is correct
19 Correct 10 ms 332 KB Output is correct
20 Correct 12 ms 460 KB Output is correct
21 Correct 7 ms 460 KB Output is correct
22 Correct 10 ms 456 KB Output is correct
23 Correct 10 ms 460 KB Output is correct
24 Correct 12 ms 492 KB Output is correct
25 Correct 9 ms 460 KB Output is correct
26 Correct 9 ms 464 KB Output is correct
27 Correct 10 ms 420 KB Output is correct
28 Correct 11 ms 460 KB Output is correct
29 Correct 16 ms 460 KB Output is correct
30 Correct 13 ms 460 KB Output is correct