Submission #216762

#TimeUsernameProblemLanguageResultExecution timeMemory
216762tushar_2658Art Exhibition (JOI18_art)C++14
50 / 100
1096 ms24696 KiB
#include "bits/stdc++.h" using namespace std; const int maxn = 500005; using ll = long long; pair<ll, ll> p[maxn]; int main(int argc, char const *argv[]) { // freopen("in.txt", "r", stdin); int n; scanf("%d", &n); for(int i = 1; i <= n; i++){ scanf("%lld %lld", &p[i].first, &p[i].second); } sort(p + 1, p + n + 1); vector<ll> pref(n + 1); for(int i = 1; i <= n; i++){ pref[i] = pref[i - 1] + p[i].second; } ll ans = -1e18; for(int i = 1; i <= n; i++){ for(int j = 1; j < i; j++){ ans = max(ans, (pref[i] - pref[j - 1]) - p[i].first + p[j].first); } ans = max(ans, pref[i] - pref[i - 1]); } cout << ans << endl; return 0; }

Compilation message (stderr)

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