Submission #162587

# Submission time Handle Problem Language Result Execution time Memory
162587 2019-11-08T20:45:17 Z fenech20 Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 256 KB
/**
 * Martin Leshko ([email protected])
 */

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define sz(a) (int)a.size()

const int N = 300001;

int main() {
  int n;
  cin >> n;
  vector< pair<int, int> > a(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = {x, y};
  }
  sort(a.begin(), a.end());
  long long prefix = 0, mn = 0x3f3f3f3f, ans = -0x3f3f3f3f;
  for (int i = 0; i < n; i++) {
    prefix += a[i].second;
    mn = min(mn, prefix - a[i].second - a[i].first);
    ans = max(ans, prefix - a[i].first - mn);
  }
  cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -