Submission #91876

#TimeUsernameProblemLanguageResultExecution timeMemory
91876AlisabziArt Exhibition (JOI18_art)C++14
100 / 100
217 ms21100 KiB
#include<bits/stdc++.h> using namespace std ; #define F first #define S second typedef long long ll ; const ll N = 5000011 ; pair<ll,int> P[N] ; int n ; ll a , b, ans; int main () { scanf("%d", &n) ; for(int i = 1 ; i <= n ; i ++){ scanf("%lld%lld", &a, &b) ; P[i].F = a, P[i].S = b; } sort(P+1, P+n+1) ; ans = a = P[1].S ; b = 0 ; for(int i = 2 ; i <= n ; i ++){ b = max(a+P[i].S-(P[i].F-P[i-1].F), (ll)P[i].S) ; ans = max(ans, b) ; a = b ; } printf("%lld", ans) ; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n) ;
  ~~~~~^~~~~~~~~~
art.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   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...