Submission #927037

#TimeUsernameProblemLanguageResultExecution timeMemory
927037AmaarsaaCloud Computing (CEOI18_clo)C++14
18 / 100
369 ms1480 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long ; const int N = 1e5 + 2; struct Com { ll c, f, v, req; }; Com C; int main() { // freopen("moocast.in", "r", stdin); // freopen("moocast.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); ll t, n, m, ans, s, sum, x, y, r, p, i, j; cin >> n; vector < Com > v; for (i = 1; i <= n; i ++) { cin >> C.c >> C.f >> C.v; C.req = 0; v.push_back(C); } cin >> m; for (i = 1; i <= m; i ++) { cin >> C.c >> C.f >> C.v; C.req = 1; v.push_back(C); } sort(v.begin(), v.end(), [](Com& A, Com& B){ if ( A.f == B.f) return A.req < B.req; return A.f > B.f; }); vector < ll > dp(N + 2, -1e9); dp[0] = 0; for (Com& A : v) { if ( A.req == 1) { for (i = 0; i + A.c <= N; i ++) { dp[i] = max(dp[i], dp[i + A.c] + A.v); } } else { for (i = N; i >= A.c; i --) { dp[i] = max(dp[i], dp[i - A.c] - A.v); } } } ans = 0; for (i= 0; i <= N; i ++) { ans =max(ans, dp[i]); } cout << ans << endl; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:15:5: warning: unused variable 't' [-Wunused-variable]
   15 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |     ^
clo.cpp:15:19: warning: unused variable 's' [-Wunused-variable]
   15 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                   ^
clo.cpp:15:22: warning: unused variable 'sum' [-Wunused-variable]
   15 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                      ^~~
clo.cpp:15:27: warning: unused variable 'x' [-Wunused-variable]
   15 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                           ^
clo.cpp:15:30: warning: unused variable 'y' [-Wunused-variable]
   15 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                              ^
clo.cpp:15:33: warning: unused variable 'r' [-Wunused-variable]
   15 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                                 ^
clo.cpp:15:36: warning: unused variable 'p' [-Wunused-variable]
   15 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                                    ^
clo.cpp:15:42: warning: unused variable 'j' [-Wunused-variable]
   15 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                                          ^
#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...