Submission #481152

#TimeUsernameProblemLanguageResultExecution timeMemory
481152aris12345678Art Exhibition (JOI18_art)C++14
50 / 100
1097 ms24504 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, int> pli;
#define X first
#define Y second

const int mxN = 500005;
pli arr[mxN];
ll pref[mxN];

int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%lld %d", &arr[i].X, &arr[i].Y);
    sort(arr+1, arr+n+1);
    for(int i = 1; i <= n; i++)
        pref[i] = 1LL*arr[i].Y+pref[i-1];
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j++) {
            ans = max(ans, (pref[j]-pref[i-1])-(arr[j].X-arr[i].X));
            // cout << i << " " << j << " " << ans << " " << (pref[j]-pref[i-1])-(arr[j].X-arr[i].X) << "\n";
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Compilation message (stderr)

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