Submission #968565

#TimeUsernameProblemLanguageResultExecution timeMemory
968565tsetArt Exhibition (JOI18_art)C++14
100 / 100
147 ms23012 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int INF = 1e18 +42; signed main() { int N; scanf("%lld", &N); vector<pair<int, int>> tab; for(int iTab = 0; iTab < N; iTab++) { int A, B; scanf("%lld%lld", &A, &B); tab.push_back({A, B}); } tab.push_back({-INF, -INF}); sort(tab.begin(), tab.end()); vector<int> cumulS(N+1, 0); for(int i= 1; i<=N; i++) { cumulS[i] = cumulS[i-1] + tab[i].second; } vector<int> bonus(N+1); for(int i=1; i<=N; i++) { bonus[i] = max(tab[i].first - cumulS[i-1], bonus[i-1]); } int ans = -INF; for(int iMax=1; iMax<= N; iMax++) { ans = max(ans, cumulS[iMax] + bonus[iMax] - tab[iMax].first); } printf("%lld\n", ans); }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%lld", &N);
      |     ~~~~~^~~~~~~~~~~~
art.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld%lld", &A, &B);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...