Submission #1106745

# Submission time Handle Problem Language Result Execution time Memory
1106745 2024-10-31T02:34:42 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
2 ms 8784 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int N = 500'000 + 10;
int n;
pair<int, int> art[N];

int f[N][2];

int32_t main() { 
  cin.tie(0)->sync_with_stdio(0);

  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> art[i].first >> art[i].second;

  sort(art + 1, art + n + 1);
  memset(f, -14, sizeof f);
  for (int i = 1; i <= n; ++i) { 
    const auto& [a, b] = art[i];
    f[i][0] = max(f[i - 1][0] + b, b + a);
    f[i][1] = max(f[i - 1][1], f[i - 1][0] + b - a);
  } 

  cout << f[n][1] << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8784 KB Output isn't correct
2 Halted 0 ms 0 KB -