Submission #47024

#TimeUsernameProblemLanguageResultExecution timeMemory
47024leejseoArt Exhibition (JOI18_art)C++17
100 / 100
293 ms12540 KiB
#include <stdio.h> #include <utility> #include <algorithm> #include <vector> using namespace std; typedef long long lld; typedef pair<lld, lld> pll; lld ans; int N; int main(void){ scanf("%d", &N); lld X, Y, S[N+1]; pll U[N]; S[0] = 0; for (int i=0; i<N; i++){ scanf("%lld%lld", &X, &Y); U[i] = make_pair(X, Y); } sort(U, U+N); for (int i=0; i<N; i++){ S[i+1] = S[i] + U[i].second; } Y = -(U[0].first); for (int i=1; i<=N; i++){ X = S[i] - U[i-1].first; ans = max(ans, X - Y); if (i == N) break; Y = min(Y, S[i]-U[i].first); } printf("%lld", ans); }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
art.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &X, &Y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...