Submission #875064

#TimeUsernameProblemLanguageResultExecution timeMemory
875064misu2005Art Exhibition (JOI18_art)C++11
Compilation error
0 ms0 KiB
#include <iostream>
#include <algorithm>

using namespace std;

struct ceva {
    long long sz, val;
} v[500005];

bool cmp(ceva x, ceva y) {
    return x.sz < y.sz;
}

long long sp[500005], pre = LLONG_MAX, maxim;
int n;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> v[i].sz >> v[i].val;
    sort(v+1, v+n+1, cmp);

    for (int i = 1; i <= n; i++) {
        sp[i] = sp[i-1] + v[i].val;
        pre = min(pre, sp[i-1] - v[i].sz);
        maxim = max(maxim, sp[i] - v[i].sz - pre);
    }
    cout << maxim;

    return 0;
}

Compilation message (stderr)

art.cpp:14:29: error: 'LLONG_MAX' was not declared in this scope
   14 | long long sp[500005], pre = LLONG_MAX, maxim;
      |                             ^~~~~~~~~
art.cpp:3:1: note: 'LLONG_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    2 | #include <algorithm>
  +++ |+#include <climits>
    3 | 
art.cpp: In function 'int main()':
art.cpp:27:9: error: 'maxim' was not declared in this scope
   27 |         maxim = max(maxim, sp[i] - v[i].sz - pre);
      |         ^~~~~
art.cpp:29:13: error: 'maxim' was not declared in this scope
   29 |     cout << maxim;
      |             ^~~~~