Submission #127254

#TimeUsernameProblemLanguageResultExecution timeMemory
127254AuldLangSyneArt Exhibition (JOI18_art)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define ll long long #define f(i, a, b) for(ll i = a; i <= b; ++i) #define ff(i, a, b) for(ll i = a; i < b; ++i) #define F(i, a, b) for(ll i = a; i >= b; --i) #define FF(i, a, b) for(ll i = a; i > b; --i) #define x first #define y second #define X real() #define Y imag() using namespace std; typedef complex<ll> P; typedef pair<ll, ll> ii; typedef tuple<ll, ll, ll> iii; const int N = 5e5+7; ll n, ans = 0, b[N], f[N], rmq[N][19]; ii a[N]; ll get_min(int post){ int loga; if(loga > 1) loga = log2(post-1); else loga = 0; return min(rmq[0][loga], rmq[post-(1<<loga)][loga]); } signed main(){ scanf("%d", &n); f(i,1,n){ scanf("%lld %lld", &a[i].x, &a[i].y); } sort(a+1, a+1+n); rmq[0][0] = -a[1].x; f(i,1,n){ f[i] = f[i-1] + a[i].y; b[i] = f[i]-a[i].x; if(i != n){ rmq[i][0] = f[i]-a[i+1].x; } } f(j,1,18){ ff(i,0,n){ if(i + (1<<j) - 1 < n){ rmq[i][j] = min(rmq[i][j-1], rmq[i+(1<<(j-1))][j-1]); } } } f(i,1,n){ ans = max(ans, b[i]-get_min(i)); } printf("%lld", ans); }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:28:16: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  scanf("%d", &n);
              ~~^
art.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
art.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &a[i].x, &a[i].y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp: In function 'long long int get_min(int)':
art.cpp:22:2: warning: 'loga' is used uninitialized in this function [-Wuninitialized]
  if(loga > 1) loga = log2(post-1);
  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...