# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260004 | 2020-08-08T22:27:55 Z | Kenzo_1114 | Cloud Computing (CEOI18_clo) | C++17 | 1 ms | 384 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 368 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |