Submission #1263644

#TimeUsernameProblemLanguageResultExecution timeMemory
1263644bachtdArt Exhibition (JOI18_art)C++20
50 / 100
103 ms8520 KiB
/*#pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline")*/ #include <bits/stdc++.h> #define int long long #define Log2(x) 63 - __builtin_clzll(x) #define pii pair<int, int> #define se second #define fi first using namespace std; const int N = 2e5 + 5; const int inf = 1e18; const int MOD = 1e9 + 7; int n, m, LOG = 1; int a[N], b[N], prf[N]; pii p[N]; main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i=1; i<=n; ++i) { cin >> p[i].fi >> p[i].se; } sort(p+1, p+n+1); for (int i=1; i<=n; ++i) { a[i]=p[i].fi; b[i]=p[i].se; prf[i]=prf[i-1]+b[i]; } int maxk=a[1]; int ans=b[1]; for (int i=2; i<=n; ++i) { maxk=max(maxk, a[i]-prf[i-1]); ans=max(ans, prf[i]-a[i]+maxk); } cout << ans; }

Compilation message (stderr)

art.cpp:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   20 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...