Submission #1234777

#TimeUsernameProblemLanguageResultExecution timeMemory
1234777JerArt Exhibition (JOI18_art)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e5 + 5; int n; pair<ll, ll> a[MAXN]; ll pre[MAXN]; #define ff first #define ss second int main() { scanf("%d", &n); ll f, s; for (int i = 0; i < n; i++) scanf("%lld%lld", &f, &s), a[i] = {f, s}; sort(a, a + n); for (int i = 0; i < n; i++) pre[i] = (i == 0) ? a[i].ss : a[i].ss + pre[i - 1]; ll res = 0; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { ll sum = (i == 0) ? pre[j] : pre[j] - pre[i - 1]; res = max(res, sum - (a[j].ff - a[i].ff)); } printf("%lld\n", res); return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
art.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%lld%lld", &f, &s), a[i] = {f, s};
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...