Submission #153818

# Submission time Handle Problem Language Result Execution time Memory
153818 2019-09-16T14:43:49 Z songc None (JOI14_ho_t2) C++14
100 / 100
20 ms 636 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

int N, M, ans;
int S[10101];
int D[20202], T[20202];

int main(){
	scanf("%d %d", &M, &N);
	for (int i=1; i<=20000; i++) D[i] = T[i] = (1<<30);
	for (int i=1; i<=M; i++) scanf("%d", &S[i]);
	sort(S+1, S+M+1, greater<int>());
	for (int i=1; i<=M; i++) S[i] += S[i-1];
	for (int i=1; i<=N; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		for (int j=0; j+x<=20000; j++) T[j+x] = min(D[j+x], D[j]+y);
		for (int j=0; j<=20000; j++) D[j] = T[j];
	}
	for (int j=19999; j>0; j--) D[j] = min(D[j], D[j+1]);
	for (int i=1; i<=M; i++) ans = max(ans, S[i]-D[i]);
	printf("%d\n", ans);
	return 0;
}

Compilation message

2014_ho_t2.cpp: In function 'int main()':
2014_ho_t2.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &M, &N);
  ~~~~~^~~~~~~~~~~~~~~~~
2014_ho_t2.cpp:13:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=1; i<=M; i++) scanf("%d", &S[i]);
                           ~~~~~^~~~~~~~~~~~~
2014_ho_t2.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 5 ms 508 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 504 KB Output is correct
2 Correct 18 ms 636 KB Output is correct
3 Correct 20 ms 632 KB Output is correct
4 Correct 20 ms 504 KB Output is correct
5 Correct 19 ms 504 KB Output is correct
6 Correct 17 ms 504 KB Output is correct
7 Correct 15 ms 504 KB Output is correct
8 Correct 18 ms 504 KB Output is correct
9 Correct 17 ms 504 KB Output is correct
10 Correct 19 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 5 ms 508 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 19 ms 504 KB Output is correct
12 Correct 18 ms 636 KB Output is correct
13 Correct 20 ms 632 KB Output is correct
14 Correct 20 ms 504 KB Output is correct
15 Correct 19 ms 504 KB Output is correct
16 Correct 17 ms 504 KB Output is correct
17 Correct 15 ms 504 KB Output is correct
18 Correct 18 ms 504 KB Output is correct
19 Correct 17 ms 504 KB Output is correct
20 Correct 19 ms 504 KB Output is correct
21 Correct 14 ms 508 KB Output is correct
22 Correct 16 ms 616 KB Output is correct
23 Correct 16 ms 504 KB Output is correct
24 Correct 16 ms 632 KB Output is correct
25 Correct 16 ms 632 KB Output is correct
26 Correct 16 ms 504 KB Output is correct
27 Correct 17 ms 504 KB Output is correct
28 Correct 18 ms 632 KB Output is correct
29 Correct 19 ms 504 KB Output is correct
30 Correct 18 ms 504 KB Output is correct