답안 #1079211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079211 2024-08-28T12:04:23 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#define task "MAXNUM"
#define pl pair<ll, ll>
#define pf push_front
#define pb push_back
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b, c) for (int i=a; i<=b; i+=c)
#define FORE(i, a, b, c) for (int i=a; i>=b; i+=c)
#define VI vector <int>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int Mod = 123456789;
const int maxn = 5e5+1;
const ll Inf = 3e9;
pl A[maxn+1];
ll B[maxn+2], C[maxn+2], sum2, sum, n, res;
void Read()
{
    cin >> n;
    FOR(i, 1, n, 1) {
        cin >> A[i].fi >> A[i].se;
        sum2 += A[i].se;
    }
}
void Solve()
{
    sort (A + 1, A + n + 1);
    FOR(i, 1, n, 1) {
        B[i] = max(B[i-1], A[i].fi - sum);
        sum += A[i].se;
    }
    FORE(i, n, 1, -1) {
        C[i] = max(C[i+1], sum2 - A[i].fi);
        sum2 -= A[i].se;
    }
    FOR(i, 1, n, 1) {
        res = max(res, C[i] + B[i]);
    }
    cout << res;
}
int main()
{
    if (fopen (task".inp", "r")) {
        freopen (task".inp", "r", stdin);
        freopen (task".out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    for (t=1; t--;)
    {
        Read(); Solve();
    }
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:49:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:50:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -