# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1091268 | nghiaaa | Cloud Computing (CEOI18_clo) | C++14 | 546 ms | 1948 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
//variable
#define ld long double
#define ll long long
#define db double
#define ii pair<int,int>
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
//vector
#define pb push_back
#define all(v) v.begin(),v.end()
#define len(a) (int)a.length()
#define sz(a) (int)a.size()
//mask
#define BIT(i) (1LL<<(i))
//better code, debugger
#define watch(n) cerr << #n << ": " << n << endl
#define debug(x) for (auto p: x) cerr<<p<<' ';cerr<<endl
#define forw(i,j,z) for(int i=(int)j;i<=(int)z;i++)
#define ford(i,j,z) for (int i=(int)j;i>=(int)z;i--)
#define fIlE "test."
//auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
//mt19937 RAND(seed);
const int mod = 998244353;
inline int add(int u,int v){u+=v;if(u>=mod)u-=mod;return u;}
inline int dec(int u,int v){u-=v;if(u<0)u+=mod;return u;}
inline int mul(int u,int v){return (ll)u*v%mod;}
const int N = 2000 + 1;
struct E{
int slot, tt, cost;
};
E a[2 * N];
bool cmp(E u, E v)
{
if (u.tt != v.tt)
return u.tt > v.tt;
return u.slot < v.slot;
}
int n, m;
void solve()
{
cin >> n;
int maxC = 0;
forw(i, 1, n){
cin >> a[i].slot >> a[i].tt >> a[i].cost;
a[i].cost *= -1;
maxC += a[i].slot;
}
cin >> m;
forw(i, n + 1, n + m){
cin >> a[i].slot >> a[i].tt >> a[i].cost;
a[i].slot *= -1;
}
sort(a + 1, a + n + m + 1, cmp);
vector<ll> dp(maxC + 1, LLONG_MIN);
dp[0] = 0;
forw(i, 1, n + m){
const E u = a[i];
vector<ll> re(dp);
forw(c, 0, maxC)
if (c + u.slot >= 0 && c + u.slot <= maxC && dp[c] != LLONG_MIN)
re[c + u.slot] = max(re[c + u.slot], dp[c] + u.cost);
dp = re;
}
cout << *max_element(all(dp));
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen(fIlE"inp", "r"))
freopen(fIlE"inp","r",stdin), freopen(fIlE"out","w",stdout);
//time_t TIME_TU=clock();
int t=1;
// cin>>t;
while(t--)
solve();
//time_t TIME_TV=clock();
//cerr<<(db)(TIME_TV-TIME_TU)/CLOCKS_PER_SEC<<endl;
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... |