답안 #1108393

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108393 2024-11-04T03:57:48 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 2384 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define pa pair<ll, ll>
#define fi first
#define se second
#define bit(mask, j) (mask & (1<<j))
const ll mod = 1e9 + 7;
const ll INF = 1e17;
const ll N = 5e5 + 10;
pa a[N];
ll s[N], ans = 0;
int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    #define NAME "hbmt"
        if(fopen(NAME".inp", "r")) {
            freopen(NAME".inp", "r", stdin);
            freopen(NAME".out", "w", stdout);
        }
    ll n;
    cin >> n;
    FOR(i, 1, n)
    {
        cin >> a[i].fi >> a[i].se;
    }
    sort(a + 1, a + n + 1);
    FOR(i, 1, n)
    {
        s[i] = s[i - 1] + a[i].se;
    }
    FOR(i, 1, n)
    {
        ll res = s[i] - a[i].fi + a[1].fi;
        ll res2 = s[n] - s[i - 1] - a[n].fi + a[i].fi;
        ans = max({ans, res, res2});
    }
    cout << ans;
    return 0;
}

Compilation message

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