제출 #1104392

#제출 시각아이디문제언어결과실행 시간메모리
1104392Lakshya108Cloud Computing (CEOI18_clo)C++17
0 / 100
27 ms592 KiB
#include <bits/stdc++.h> using namespace std; // Macros #define pb push_back #define pf push_front #define ff firstw #define ss second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define up(v) upper_bound(v) #define low(v) lower_bound(v) // #define rep(i, x, n) for(int i = x; i < n; ++i) // #define rrep(i, x, n) for(int i = x; i >= n; --i) // Read and Print #define read(a, n) for(ll i = 0; i < n; ++i) cin >> a[i]; #define print(a, n) for(ll i = 0; i < n; ++i){ cout << a[i] << " ";} cout << "\n"; #define endl "\n" #define sp " " // Typedefs typedef long long ll; typedef long double ld; typedef long long int lli; typedef pair <ll, ll> pll; typedef pair <lli, lli> plli; typedef pair <int, int> pii; typedef vector <lli> vi; typedef vector <vector <lli>> vvi; using vec = vector<int>; // Constants const ll mxn = 1e6 + 5; const ll mod = 1e9 + 7; // Solve const ll N = 1e5 + 5; void solve(){ ll n; cin>>n; vi c(n), f(n), v(n); vector<tuple<int, int, int>> a; ll sum = 0; for(ll i = 0; i<n; i++){ cin>>c[i]>>f[i]>>v[i]; a.pb({f[i], c[i], -v[i]}); sum+=c[i]; } int m; cin>>m; vector<int> C(m),F(m),V(m); for(int i = 0; i<n; i++){ cin>>C[i]>>F[i]>>V[i]; a.pb({F[i], C[i], V[i]}); } sort(rall(a)); vi dp(sum+1, -1e8); // cout<<sum<<endl; dp[0] = 0; for(auto [i,j,k] : a){ if(k > 0){ for(int l=j;l<=sum;l++){ dp[l-j] = max(dp[l-j],dp[l]+k); } } else{ for(int l=sum-j;l>=0;l--){ dp[l+j] = max(dp[l+j],dp[l]+k); } } } sort(rall(dp)); // for(auto &x:dp) cout<<x<<endl; // cout<<endl; cout<<dp[0]<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }
#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...