답안 #1088882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088882 2024-09-15T12:10:22 Z HienTD Art Exhibition (JOI18_art) C++14
0 / 100
3 ms 8280 KB
#include <bits/stdc++.h>
using namespace std;

//#define USACO

#define             fi  first
#define             se  second
#define           TIME  (1.0 * clock() / CLOCKS_PER_SEC)
#define         ALL(v)  (v).begin(), (v).end()
#define         BIT(x)  (1LL << (x))
#define     MASK(x, i)  (((x) >> (i)) & 1)
#define   FOR(i, a, b)  for(int i = (a), _b = (b); i <= _b; ++ i)
#define  FORD(i, b, a)  for(int i = (b), _a = (a); i >= _a; -- i)

const string NAME = "BAITAP";

const string name = "";

const long long INF = 1e18;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int mod = 998244353;

const int mxN = 5e5 + 5;

int N;
vector<pair<long long, int>> A(mxN);

void init(void){
    cin >> N;
    FOR(i, 1, N) cin >> A[i].fi >> A[i].se;
}

void process(void){
    sort(A.begin() + 1, A.begin() + 1 + N);
    long long mx = -1;
    long long mn = INF;
    long long val = 0;
    long long ans = 0;
    FOR(i, 1, N){
        mx = max(mx, A[i].fi);
        mn = min(mn, A[i].fi);
        val += A[i].se;
        ans = max(ans, val - (mx - mn));
        //cerr << i << ' ' << mx << ' ' << mn << ' ' << val << ' ' << A[i].fi << ' ' << A[i].se << ' ' << ans << '\n';
    }
    cout << ans;
}

signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    #ifdef LOCAL
        freopen((NAME + ".INP").c_str(), "r", stdin);
        freopen((NAME + ".OUT").c_str(), "w", stdout);
    #elif defined(USACO)
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    #endif // I/O

    init();
    process();
    cerr << "\nTime elapsed: " << TIME << "s.\n";
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -