제출 #39682

#제출 시각아이디문제언어결과실행 시간메모리
3968214kg만두 팔기 (JOI14_manju)C++11
25 / 100
1000 ms25660 KiB
#include <stdio.h>
#include <algorithm>
#define min2(x,y) (x<y?x:y)

using namespace std;
struct BOX {
	int cnt, value;
} box[501];
int n, m, in[10001], p[10001];
int dp[501][10001];
bool check[501][10001];

int max2(int x, int y) { return x > y ? x : y; }
int f(int x, int y) {
	if (x == 0 || y == 0) return 0;
	if (!check[x][y]) {
		int cnt = min2(y, box[x].cnt);
		dp[x][y] = max2(f(x - 1, y), f(x - 1, y - cnt) + p[y] - p[y - cnt] - box[x].value);
	} return dp[x][y];
}
int main() {
	scanf("%d %d", &m, &n);
	for (int i = 1; i <= m; i++) scanf("%d", &in[i]);
	for (int i = 1; i <= n; i++) scanf("%d %d", &box[i].cnt, &box[i].value);

	sort(in + 1, in + m + 1);
	for (int i = 1; i <= m; i++) p[i] = p[i - 1] + in[i];
	printf("%d", f(n, m));
}

컴파일 시 표준 에러 (stderr) 메시지

t2.cpp: In function 'int main()':
t2.cpp:22:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &m, &n);
                        ^
t2.cpp:23:50: 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", &in[i]);
                                                  ^
t2.cpp:24:73: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= n; i++) scanf("%d %d", &box[i].cnt, &box[i].value);
                                                                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...