# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260004 | Kenzo_1114 | Cloud Computing (CEOI18_clo) | C++17 | 1 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2010;
int n, m;
long long c[MAXN], C[MAXN], f[MAXN], F[MAXN], v[MAXN], V[MAXN];
bool cmp(pair<long long int, long long int> a, pair<long long int, long long int>b)
{
if(a.first != b.first) return a.first > b.first;
return a.second < b.second;
}
bool cmp2(pair<long long int, long long int>a, pair<long long int, long long int>b)
{
if(a.second != b.second) return a.second > b.second;
return a.first < b.first;
}
int main ()
{
scanf("%d", &n);
vector<pair<long long int, long long int> > aux[2];
for(int i = 0; i < n; i++)
{
scanf("%lld %lld %lld", &c[i], &f[i], &v[i]);
aux[0].push_back(make_pair(c[i], v[i]));
}
scanf("%d", &m);
for(int i = 0; i < m; i++)
{
scanf("%lld %lld %lld", &C[i], &F[i], &V[i]);
aux[1].push_back(make_pair(C[i], V[i]));
}
sort(aux[0].begin(), aux[0].end(), cmp);
sort(aux[1].begin(), aux[1].end(), cmp2);
int j = 0;
long long SC = 0, SV = 0, Sc = aux[0][0].first, Sv = aux[0][0].second, ans = 0;
// for(int i = 0; i < n; i++) printf("c = %lld v = %lld\n", aux[0][i].first, aux[0][i].second);
// for(int i = 0; i < m; i++) printf("C = %lld V = %lld\n", aux[0][i].first, aux[0][i].second);
for(int i = 1; i < n; i++)
{
while(j < m && Sc >= SC + aux[1][j].first)
{
if(Sc >= SC) ans = max(ans, SV - Sv);
SC += aux[1][j].first;
SV += aux[1][j].second;
j++;
}
if(Sc >= SC) ans = max(ans, SV - Sv);
Sc += aux[0][i].first;
Sv += aux[0][i].second;
}
if(Sc >= SC) ans = max(ans, SV - Sv);
printf("%lld\n", ans);
}
Compilation message (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... |