Submission #260004

#TimeUsernameProblemLanguageResultExecution timeMemory
260004Kenzo_1114Cloud Computing (CEOI18_clo)C++17
0 / 100
1 ms384 KiB
#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)

clo.cpp: In function 'int main()':
clo.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
clo.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld", &c[i], &f[i], &v[i]); 
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &m);
  ~~~~~^~~~~~~~~~
clo.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld", &C[i], &F[i], &V[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...