제출 #482994

#제출 시각아이디문제언어결과실행 시간메모리
482994Lam_lai_cuoc_doiCloud Computing (CEOI18_clo)C++17
100 / 100
308 ms1228 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; template <class T> void read(T &x) { x = 0; register int c; while ((c = getchar()) && (c > '9' || c < '0')) ; for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0'; } constexpr bool typetest = 0; constexpr int N = 2e3 + 5; constexpr ll Inf = 1e17; struct Object { int c, f, v; bool seller; bool operator<(const Object &a) const { return f < a.f || (f == a.f && !seller && a.seller); } } a[N * 2]; ll dp[N * 50]; int n, m; void Read() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i].c >> a[i].f >> a[i].v; a[i].seller = 1; } cin >> m; for (int i = n + 1; i <= n + m; ++i) cin >> a[i].c >> a[i].f >> a[i].v; } inline void Max(ll &x, ll y) { if (x < y) x = y; } void Solve() { sort(a + 1, a + m + n + 1); fill_n(dp, N * 50, -Inf); dp[0] = 0; for (int i = 1, cnt(0); i <= m + n; ++i) { if (a[i].seller) { for (int j = 0; j <= cnt; ++j) Max(dp[max(0, j - a[i].c)], dp[j] - a[i].v); } else { for (int j = cnt; ~j; --j) Max(dp[j + a[i].c], dp[j] + a[i].v); cnt += a[i].c; } } cout << dp[0]; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("xor.INP", "r")) { freopen("xor.inp", "r", stdin); freopen("xor.out", "w", stdout); } int t(1); if (typetest) cin >> t; for (int _ = 1; _ <= t; ++_) { // cout << "Case #" << _ << ": "; Read(); Solve(); } // cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; }

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

clo.cpp: In function 'void read(T&)':
clo.cpp:12:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   12 |     register int c;
      |                  ^
clo.cpp: In function 'int32_t main()':
clo.cpp:91:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   91 |         freopen("xor.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:92:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   92 |         freopen("xor.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...