# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1273477 | kausarme | Cloud Computing (CEOI18_clo) | C++20 | 349 ms | 327680 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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |