제출 #20840

#제출 시각아이디문제언어결과실행 시간메모리
20840kdh9949만두 팔기 (JOI14_manju)C++14
100 / 100
39 ms41536 KiB
#include <bits/stdc++.h> using namespace std; int n, m, a[10010], b[505], c[505], dp[505][20010], ans; int main(){ scanf("%d%d", &n, &m); for(int i = 1; i <= n; i++) scanf("%d", a + i); for(int i = 1; i <= m; i++) scanf("%d%d", c + i, b + i); fill(dp[0] + 1, dp[0] + n + 10001, 1e9); for(int i = 1; i <= m; i++){ for(int j = 1; j <= n + 10000; j++){ dp[i][j] = dp[i - 1][j]; if(j >= c[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - c[i]] + b[i]); } } for(int i = n + 9999; i >= 1; i--) dp[m][i] = min(dp[m][i], dp[m][i + 1]); sort(a + 1, a + n + 1, greater<int>()); for(int i = 1; i <= n; i++){ a[i] += a[i - 1]; ans = max(ans, a[i] - dp[m][i]); } printf("%d\n", ans); }

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

t2.cpp: In function 'int main()':
t2.cpp:7:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
                       ^
t2.cpp:8:48: 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", a + i);
                                                ^
t2.cpp:9:57: 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%d", c + i, b + i);
                                                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...