Submission #698913

#TimeUsernameProblemLanguageResultExecution timeMemory
698913RichemArt Exhibition (JOI18_art)C++14
0 / 100
0 ms212 KiB
#include <iostream> #include <algorithm> #define int long long using namespace std; const int MAX_NOMBRE = 5e5+42; pair<int, int> tableau[MAX_NOMBRE]; int nbTableau; signed main() { cin >> nbTableau; for(int i = 0; i < nbTableau; i++) { cin >> tableau[i].first >> tableau[i].second; } sort(tableau, tableau + nbTableau); int fin = 0, valOpti = 0, sommeCur = 0; for(int i = 0; i < nbTableau; i++) { sommeCur += tableau[i].second; int valCur = sommeCur - tableau[i].first + tableau[0].first; if(valCur > valOpti) { valOpti = valCur; fin = i; } } valOpti = 0; sommeCur = 0; for(int i = fin; i >= 0; i--) { sommeCur += tableau[i].second; int valCur = sommeCur - tableau[fin].first + tableau[i].first; valOpti = max(valOpti, valCur); } cout << valOpti; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...