답안 #55135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55135 2018-07-06T06:02:58 Z 김세빈(#1527) 만두 (JOI14_ho_t2) C++11
100 / 100
16 ms 800 KB
#include <bits/stdc++.h>

using namespace std;

int D[10101], C[10101];
int n, m, ans;

int main()
{
	int i, j, a, b;
	
	scanf("%d%d", &n, &m);
	
	for(i=1;i<=n;i++){
		scanf("%d", C+i);
		D[i] = 1e9;
	}
	D[n+1] = 1e9;
	
	sort(C+1, C+n+1);
	reverse(C+1, C+n+1);
	
	for(i=1;i<=n;i++){
		C[i] += C[i-1];
	}
	
	for(i=1;i<=m;i++){
		scanf("%d%d", &a, &b);
		for(j=n;j>n-a;j--){
			D[n+1] = min(D[n+1], D[j] + b);
		}
		for(j=n;j>=a;j--){
			D[j] = min(D[j], D[j-a] + b);
		}
	}
	
	m = D[n+1];
	for(i=n;i>=0;i--){
		m = min(m, D[i]);
		ans = max(ans, C[i] - m);
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Compilation message

2014_ho_t2.cpp: In function 'int main()':
2014_ho_t2.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
2014_ho_t2.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", C+i);
   ~~~~~^~~~~~~~~~~
2014_ho_t2.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 5 ms 484 KB Output is correct
4 Correct 4 ms 564 KB Output is correct
5 Correct 3 ms 628 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 3 ms 800 KB Output is correct
8 Correct 2 ms 800 KB Output is correct
9 Correct 4 ms 800 KB Output is correct
10 Correct 4 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 800 KB Output is correct
2 Correct 8 ms 800 KB Output is correct
3 Correct 9 ms 800 KB Output is correct
4 Correct 10 ms 800 KB Output is correct
5 Correct 11 ms 800 KB Output is correct
6 Correct 3 ms 800 KB Output is correct
7 Correct 8 ms 800 KB Output is correct
8 Correct 8 ms 800 KB Output is correct
9 Correct 3 ms 800 KB Output is correct
10 Correct 8 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 5 ms 484 KB Output is correct
4 Correct 4 ms 564 KB Output is correct
5 Correct 3 ms 628 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 3 ms 800 KB Output is correct
8 Correct 2 ms 800 KB Output is correct
9 Correct 4 ms 800 KB Output is correct
10 Correct 4 ms 800 KB Output is correct
11 Correct 9 ms 800 KB Output is correct
12 Correct 8 ms 800 KB Output is correct
13 Correct 9 ms 800 KB Output is correct
14 Correct 10 ms 800 KB Output is correct
15 Correct 11 ms 800 KB Output is correct
16 Correct 3 ms 800 KB Output is correct
17 Correct 8 ms 800 KB Output is correct
18 Correct 8 ms 800 KB Output is correct
19 Correct 3 ms 800 KB Output is correct
20 Correct 8 ms 800 KB Output is correct
21 Correct 10 ms 800 KB Output is correct
22 Correct 11 ms 800 KB Output is correct
23 Correct 8 ms 800 KB Output is correct
24 Correct 13 ms 800 KB Output is correct
25 Correct 11 ms 800 KB Output is correct
26 Correct 16 ms 800 KB Output is correct
27 Correct 5 ms 800 KB Output is correct
28 Correct 10 ms 800 KB Output is correct
29 Correct 11 ms 800 KB Output is correct
30 Correct 12 ms 800 KB Output is correct