| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1360654 | kai | Cloud Computing (CEOI18_clo) | C++20 | 408 ms | 2188 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el '\n'
#define all(x) begin(x), end(x)
#define sz(s) (int)(s.size())
inline void setIO(string s) {
if(fopen((s + ".in").c_str(), "r")){
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
}
const int MOD = 1e9+7; //998244353;
const int N = 1e5 + 36;
const int NEG = -1e16;
int dp[N], ndp[N];
int n, m;
void Solve(){
memset(dp, -0x3f, sizeof dp);
vector<array<int, 3>> vt;
int c, f, v;
int sum_c = 0;
cin>> n;
for(int i=0; i<n; i++){
cin>> c>> f>> v;
vt.push_back({c, f, -v});
sum_c += c;
}
cin>> m;
for(int i=0; i<m; i++){
cin>> c>> f>> v;
vt.push_back({-c, f, v});
}
sort(all(vt), [](array<int, 3> a, array<int, 3> b){
if(a[1] != b[1]) return a[1] > b[1];
return a[0] > b[0];
});
dp[0] = 0;
for(auto [cores, f, v]: vt){
for(int c=0; c<=sum_c; c++) ndp[c] = dp[c];
for(int c=0; c<=sum_c; c++){
if(dp[c] <= NEG) continue;
int nc = c + cores;
if(nc >= 0 && nc <= sum_c){
ndp[nc] = max(ndp[nc], dp[c] + v);
}
}
swap(dp, ndp);
}
int ans = 0;
for(int c=0; c<=sum_c; c++) ans = max(ans, dp[c]);
cout<< ans<<el;
}
signed main (){
setIO("Rem");
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T(1);
// cin >> T;
while(T--) Solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
