제출 #202948

#제출 시각아이디문제언어결과실행 시간메모리
202948AlexPop28Art Exhibition (JOI18_art)C++11
100 / 100
243 ms20988 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n; cin >> n;
  vector<pair<long long, int>> v(n);
  for (auto &p : v) {
    cin >> p.first >> p.second;
  }

  sort(v.begin(), v.end());

  long long ans = numeric_limits<long long>::min();
  long long s = 0, mn = numeric_limits<long long>::max();
  for (int i = 0; i < n; ++i) {
    long long curr = s - v[i].first;
    s += v[i].second;
    mn = min(mn, curr);
    ans = max(ans, s - mn - v[i].first);
  }
  cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...