Submission #675151

#TimeUsernameProblemLanguageResultExecution timeMemory
675151CookieCloud Computing (CEOI18_clo)C++14
100 / 100
801 ms2132 KiB
#include<bits/stdc++.h> using namespace std; #include<fstream> #define ll long long #define vt vector #define pb push_back #define fi first #define se second #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) typedef unsigned long long ull; #define pii pair<int, int> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") const ll mod= 1e9 + 7; const int mxk = 1e3, sq = 750, mxn = 105; const ll inf = -1e18; int n, m; ll d[2][2002][51], p[2005]; struct th{ ll c, f, v; bool operator <(const th &b){ if(f != b.f)return(f > b.f); return(v < b.v); } }; vt<th>a, b; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; ll core = 0; forr(i, 0, n){ int c, f, v; cin >> c >> f >> v; a.pb({c, f, -v}); core += c; } cin >> m; forr(i, 0, m){ int c, f, v; cin >> c >> f >> v; a.pb({-c, f, v}); } sort(a.begin(), a.end()); vt<ll>pre; pre.resize(core + 1, inf); pre[0] = 0; for(auto [c, f, v]: a){ vt<ll>curr; curr.resize(core + 1); for(int j = 0; j <= core; j++)curr[j] = pre[j]; for(int i = 0; i <= core; i++){ int lft = i - c; if(lft >= 0 && lft <= core && pre[lft] != inf){ curr[i] = max(curr[i], pre[lft] + v); } } for(int j = 0; j <= core; j++)pre[j] = curr[j]; } cout << *max_element(pre.begin(), pre.end()); return(0); }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:46:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   46 |     for(auto [c, f, v]: a){
      |              ^
#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...