답안 #151418

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151418 2019-09-02T19:46:54 Z TadijaSebez 만두 (JOI14_ho_t2) C++11
100 / 100
14 ms 540 KB
#include <bits/stdc++.h>
using namespace std;
const int M=20050;
const int inf=1e9+7;
int p[M],dp[M];
int main()
{
	int n,m,c,e;
	scanf("%i %i",&m,&n);
	for(int i=1;i<=m;i++) scanf("%i",&p[i]);
	sort(p+1,p+1+m);reverse(p+1,p+1+m);
	for(int i=1;i<M;i++) dp[i]=inf;
	while(n--)
	{
		scanf("%i %i",&c,&e);
		for(int i=M-1;i>=c;i--) dp[i]=min(dp[i],dp[i-c]+e);
	}
	for(int i=m+1;i<M;i++) dp[m]=min(dp[m],dp[i]);
	int ans=0;
	for(int i=1;i<=m;i++) p[i]+=p[i-1],ans=max(ans,p[i]-dp[i]);
	printf("%i\n",ans);
	return 0;
}

Compilation message

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