# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1113997 | ntdaccode | Cloud Computing (CEOI18_clo) | C++17 | 157 ms | 262144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fori(i,a,b) for(int i = a;i <= b; i++)
#define int long long
using namespace std;
typedef pair<int,int> ii;
typedef tuple<int,int,int> tp;
const int M = 1e5 + 10;
const int N = 2e3 + 10;
const int mod = 1e9 + 7;
int n , m ;
struct node
{
int c,f,v;
}buy[N],sell[N];
bool cmp(const node & a, const node & b) {
return a.f < b.f;
}
vector<int> f[N];
int kq = 0;
int g[M];
int upper[N];
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if(fopen("1.inp","r"))
{
freopen("1.inp","r",stdin);
freopen("1.out","w",stdout);
}
#define task ""
if(fopen(task".inp","r"))
{
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
cin >> n ;
for(int i = 1;i <= n ; i++) cin >> buy[i].c >> buy[i].f >> buy[i].v;
cin >> m;
for(int i = 1;i <= m ; i++) cin >> sell[i].c >> sell[i].f >> sell[i].v;
sort(buy + 1, buy + n + 1,cmp);
sort(sell + 1,sell + m + 1,cmp);
int j = n,sum = 0 ,idx = 0;
for(int i = m; i != 0; i--) {
while(sell[i].f <= buy[j].f && j != 0) sum += buy[j].c,j--;
f[i].assign(sum + 1,-1e15);
f[i][0] = 0;
upper[i] = j + 1;
if(upper[i] != n + 1 && idx == 0) idx = i;
}
j = n ,sum = 0;
for(int i = m;i != 0; i--) {
int lim = f[i+1].size();
lim--;
for(int e = 0;e <= lim; e++) f[i][e] = max(f[i][e],f[i+1][e]);
while(upper[i] <= j) {
sum += buy[j].c;
for(int e = sum ; e >= buy[j].c ; e--) {
f[i][e] = max(f[i][e],f[i][e - buy[j].c] - buy[j].v);
}
j--;
}
for(int e = sell[i].c;e <= f[i].size() - 1; e++) {
f[i][e - sell[i].c] = max(f[i][e - sell[i].c],f[i][e] + sell[i].v);
kq = max(f[i][e - sell[i].c],kq);
}
}
cout << kq;
}
컴파일 시 표준 에러 (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... |