제출 #317381

#제출 시각아이디문제언어결과실행 시간메모리
317381HeheheCloud Computing (CEOI18_clo)C++14
0 / 100
16 ms1152 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define all(a) (a).begin(), (a).end() #define forn(i,a,b) for (int i = a; i <= b; i++) #define ff first #define ss second #define pb push_back #define mp make_pair #define rc(s) return cout<<s,0 #define pi pair <int, int> #define sz(x) (int)((x).size()) #define make_unique(v) v.erase(unique(all(v)),v.end()) #define int long long const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; const ll inf = 0x3f3f3f3f3f3f3f; const ll mod = 1e9 + 7; const int N = 4000 + 11; const ll INF64 = 3e18 + 1; const int D = 2e5 + 11; int n,m,dp[D]; struct ye{ int f,p,c,tip; }; bool bo(ye x,ye y){ if(x.f >= y.f)return 1; return 0; } ye a[N]; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i].c >> a[i].f >> a[i].p; a[i].tip = 0; } cin >> m; for(int i = n + 1; i <= n + m; i++){ cin >> a[i].c >> a[i].f >> a[i].p; a[i].tip = 1; } n += m; sort(a + 1, a + n + 1, bo); for(int i = 1; i <= 1e5; i++)dp[i] = -2e18; for(int i = 1; i <= n; i++){ int cur = a[i].tip; if(cur == 0){ for(int j = 1e5; j >= a[i].c; j--){ dp[j] = max(dp[j] , dp[j-a[i].c] - a[i].p); } for(int j = a[i].c; j >= 1; j--){ dp[j] = max(dp[j] , - a[i].p); } }else{ for(int j = 1e5; j >= a[i].c; j--){ if(dp[j]!=-2e18)dp[j] += a[i].p; } } } int ans = 0; for(int i = 1; i <= 1e5; i++)ans = max(ans , dp[i]); cout << ans; 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...