Submission #971857

#TimeUsernameProblemLanguageResultExecution timeMemory
971857SunbaeArt Exhibition (JOI18_art)C++17
100 / 100
161 ms24916 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int N = 5e5 + 5; ll qs[N]; pair<ll,ll> A[N]; ll f(int i){ if(i < 0) return 0; return qs[i]; } signed main(){ int n; scanf("%d", &n); for(int i = 0; i<n; ++i){ ll a, b; scanf("%lld %lld", &a, &b); A[i] = make_pair(a, b); } sort(A, A+n); for(int i = 0; i<n; ++i){ qs[i] = A[i].second; if(i) qs[i] += qs[i-1]; } ll mx = LLONG_MIN, ans = LLONG_MIN; for(int i = 0; i<n; ++i){ mx = max(mx, A[i].first - f(i-1)); ans = max(ans, mx + qs[i] - A[i].first); } printf("%lld\n", ans); }

Compilation message (stderr)

art.cpp: In function 'll f(int)':
art.cpp:8:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    8 |  if(i < 0) return 0; return qs[i];
      |  ^~
art.cpp:8:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    8 |  if(i < 0) return 0; return qs[i];
      |                      ^~~~~~
art.cpp: In function 'int main()':
art.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  int n; scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
art.cpp:13:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   ll a, b; 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...