Submission #1273477

#TimeUsernameProblemLanguageResultExecution timeMemory
1273477kausarmeCloud Computing (CEOI18_clo)C++20
0 / 100
349 ms327680 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); typedef long long ll;typedef long double ld;typedef pair<int,int> pii; const ll mod = 1e9+7, N = 2e6+7, M = 2e6+7, INF = INT_MAX/10; ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;} void solve(){ const ll NEG = -1e18; vector<pair<ll, pair<ll,ll>>> ev; ll n; cin >> n; for(int i = 0; i < n; i++){ ll c, f, v; cin >> c >> f >> v; ev.push_back({f, {c, -v}}); } ll m; cin >> m; for(int i = 0; i < m; i++){ ll C, F, V; cin >> C >> F >> V; ev.push_back({F, {-C, V}}); } sort(ev.begin(), ev.end()); const int MAXC = 100000; vector<ll> dp(MAXC+1, NEG); dp[0] = 0; for(int idx = (int)ev.size() - 1; idx >= 0; idx--){ ll k = ev[idx].second.first; // cores ll p = ev[idx].second.second; // profit if(k > 0){ for(int used = MAXC - k; used >= 0; used--){ dp[used + k] = max(dp[used + k], dp[used] + p); } } else { for(int used = -k; used <= MAXC; used++){ dp[used + k] = max(dp[used + k], dp[used] + p); } } } ll ans = 0; for(int i = 0; i <= MAXC; i++) ans = max(ans, dp[i]); cout << ans << "\n"; } signed main(){ fast; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t = 1; while(t--){ solve(); } return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:56:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:57:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |     freopen("output.txt", "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...