제출 #1307062

#제출 시각아이디문제언어결과실행 시간메모리
1307062nanaseyuzuki만두 팔기 (JOI14_manju)C++20
100 / 100
18 ms4516 KiB
#include <bits/stdc++.h> // Kazusa_Megumi #define int long long #define fi first #define se second #define pii pair<int, int> #define all(a) a.begin(), a.end() using namespace std; const int mn = 5e5 + 5, mod = 1e9 + 7, inf = 2e18; int m, n, p[mn], dp[mn]; void solve() { cin >> m >> n; for(int i = 1; i <= m; i++) cin >> p[i]; sort(p + 1, p + m + 1, greater <int> ()); fill(dp, dp + mn, inf); dp[0] = 0; for(int i = 1; i <= n; i++){ int e, c; cin >> c >> e; for(int i = m; i >= 0; i--) dp[min(m, i + c)] = min(dp[min(m, i + c)], dp[i] + e); for(int i = m; i >= 0; i--) dp[i - 1] = min(dp[i], dp[i - 1]); } int ans = 0, cur = 0; for(int i = 1; i <= m; i++){ cur += p[i], ans = max(ans, cur - dp[i]); } cout << ans << '\n'; } main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if (fopen("Kazuki.INP", "r")) { freopen("Kazuki.INP", "r", stdin); freopen("Kazuki.OUT", "w", stdout); } int t = 1; // cin >> t; while (t--) solve(); return 0; }

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

t2.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main() {
      | ^~~~
t2.cpp: In function 'int main()':
t2.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen("Kazuki.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
t2.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen("Kazuki.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...