Submission #126157

# Submission time Handle Problem Language Result Execution time Memory
126157 2019-07-07T06:37:09 Z AlexLuchianov Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

#define ll long long
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 500000;
ll const inf = 1000000000000000;

struct number{
  ll cost;
  ll sz;
  bool operator < (number const &a) const{
    return sz < a.sz;
  }
};
number v[1 + nmax];
ll sum[1 + nmax];

int main()
{
  int n;
  cin >> n;
  for(int i = 1;i <= n; i++){
    cin >> v[i].sz >> v[i].cost;
  }
  sort(v + 1, v + n + 1);
  for(int i = 1;i <= n ; i++)
    sum[i] = sum[i - 1] + v[i].cost;

  ll smax = -inf;
  ll smin = inf;
  for(int i = 1;i <= n; i++){
    smax = MAX(smax, sum[i] - v[i].sz - smin);
    smin = MIN(smin, sum[i - 1] - v[i].sz);
  }
  cout << smax;

  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -