Submission #41097

#TimeUsernameProblemLanguageResultExecution timeMemory
41097IvanCArt Exhibition (JOI18_art)C++14
100 / 100
290 ms12508 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> ii; const int MAXN = 5*1e5 + 10; ii vetor[MAXN]; ll soma[MAXN],maximo,N,ans; int main(){ scanf("%lld",&N); for(ll i = 1;i<=N;i++){ scanf("%lld %lld",&vetor[i].first,&vetor[i].second); } sort(vetor+1,vetor+N+1); for(ll i = 1;i<=N;i++){ soma[i] = soma[i-1] + vetor[i].second; } maximo = soma[N] - vetor[N].first; for(ll i = N;i>=1;i--){ maximo = max(maximo, soma[i] - vetor[i].first ); ans = max(ans, maximo + vetor[i].first - soma[i-1] ); } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:9:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&N);
                  ^
art.cpp:11:54: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&vetor[i].first,&vetor[i].second);
                                                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...