Submission #959717

#TimeUsernameProblemLanguageResultExecution timeMemory
959717alo_54Art Exhibition (JOI18_art)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; const int oo = 1e9 + 7; void opt() { ios_base :: sync_with_stdio(false); cin.tie(nullptr); } struct Artwork { bool operator< (Artwork otro) const { return size < otro.size; } int size, value; }; int main() { opt(); int n; cin>>n; Artwork candidates[n]; for (int i = 0; i < n; i++) { cin>>candidates[i].size>>candidates[i].value; } sort(candidates, candidates + n); int sumAc[n]; int aux = 0; for (int i = 0; i < n; i++) { aux += candidates[i].value; sumAc[i] = aux; } int maxR = -oo; for (int i = 0; i < n - 1; i++) { int ini = i; for (int j = ini + 1; j < n; j++) { int fin = j; int cost; if (i == 0) { cost = sumAc[j]; }else { cost = sumAc[j] - sumAc[ini - 1]; } cost -= (candidates[fin].size - candidates[ini].size); maxR = max(maxR, cost); } } cout<<maxR<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...