Submission #455079

#TimeUsernameProblemLanguageResultExecution timeMemory
455079Nima_NaderiCloud Computing (CEOI18_clo)C++14
72 / 100
874 ms2116 KiB
//In the name of God #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll MXN = 4e3 + 10; const ll MXM = 2e5 + 10; const ll INF = 1e15; ll n, m; ll M[MXN], F[MXN], T[MXN], Ind[MXN], dp[MXM]; bool Tp[MXN]; void ckmx(ll &x, ll y){ x = max(x, y); } int main(){ ios::sync_with_stdio(0);cin.tie(0); cout.tie(0); cin >> n, iota(Ind + 1, Ind + MXN, 1); for(int i = 1; i <= n; i ++) cin >> T[i] >> F[i] >> M[i]; cin >> m; for(int i = 1; i <= m; i ++) cin >> T[i + n] >> F[i + n] >> M[i + n], Tp[i + n] = 1; sort(Ind + 1, Ind + n + m + 1, [&](const int &i, const int &j){ return F[i] > F[j]; }); fill(dp, dp + MXM, -INF), dp[0] = 0; for(int ii = 1; ii <= n + m; ii ++){ int i = Ind[ii]; if(!Tp[i]) for(int j = MXM - 1; j >= T[i]; -- j) ckmx(dp[j], dp[j - T[i]] - M[i]); else for(int j = 0; j < MXM - T[i]; j ++) ckmx(dp[j], dp[j + T[i]] + M[i]); } cout << *max_element(dp, dp + MXM) << '\n'; return 0; } // N.N

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:16:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   16 |  for(int i = 1; i <= n; i ++) cin >> T[i] >> F[i] >> M[i]; cin >> m;
      |  ^~~
clo.cpp:16:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   16 |  for(int i = 1; i <= n; i ++) cin >> T[i] >> F[i] >> M[i]; cin >> m;
      |                                                            ^~~
#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...