Submission #1321803

#TimeUsernameProblemLanguageResultExecution timeMemory
1321803vuqar_bazarov1Art Exhibition (JOI18_art)C++20
50 / 100
1095 ms8248 KiB
/*
* * author: attacker
* * created: 08.02.2026 17:56:27
*/
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

#define mt_rng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  vector<pair<int64_t, int64_t>> a(n);
  for (auto& [w, v] : a) {
    cin >> w >> v;
  }
  sort(a.begin(), a.end());
  int64_t ans = 0;
  for (int i = 0; i < n; i++) {
    int64_t s = 0, mx = -1, mn = int64_t(1e18);
    for (int j = i; j < n; j++) {
      auto [w, v] = a[j];
      s += v;
      mx = max(mx, w);
      mn = min(mn, w);
      ans = max(ans, s - mx + mn);
    }
  }
  cout << ans << '\n';
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...