Submission #988985

#TimeUsernameProblemLanguageResultExecution timeMemory
988985parlimoosCloud Computing (CEOI18_clo)C++14
0 / 100
129 ms262144 KiB
//Be Name KHODA #pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define pp pop_back #define lb lower_bound #define ub upper_bound #define arr(x) array<ll , x> #define endl '\n' #define cl clear #define bg begin int n , m , sum; vector<int> ord; vector<arr(3)> a; ll dp[4000][10000] , o; ll f(int i , int j){ if(dp[i][j] != -1) return dp[i][j]; if(i >= n + m or j >= sum) return 0; dp[i][j] = f(i + 1 , j); dp[i][j] = max(dp[i][j] , f(i , j + 1)); if(j + a[i][0] <= sum and ord[j] >= a[i][1]){ dp[i][j] = max(dp[i][j] , a[i][2] + f(i + 1 , j + a[i][0])); } return dp[i][j]; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 0 ; i < n ; i++){ int c , f , v; cin >> c >> f >> v; a.pb({c , f , v}) , o -= (1ll * v) , sum += c; for(int i = 0 ; i < c ; i++) ord.pb(f); } cin >> m; for(int i = 0 ; i < m ; i++){ int c , f , v; cin >> c >> f >> v; a.pb({c , f , v}); } fill(&dp[0][0] , &dp[3999][10000] , -1); sort(a.bg() , a.end() , [](arr(3) a , arr(3) b){ return (a[1] < b[1]); }); sort(ord.bg() , ord.end()); cout << f(0 , 0) + o; }
#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...