답안 #1088902

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088902 2024-09-15T13:39:15 Z HienTD Art Exhibition (JOI18_art) C++14
50 / 100
1000 ms 25416 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, long long>> A(mxN);

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

struct cmp{
    bool operator() (const pair<long long, long long> &a, const pair<long long, long long> &b){
        return (a.fi != b.fi ? a.fi < b.fi : a.se > b.se);
    }
};

void process(void){
    long long ans = -INF;
    long long mx = -INF;
    sort(A.begin() + 1, A.begin() + 1 + N, cmp());
    FOR(i, 1, N) cerr << i << ' ' << A[i].fi << ' ' << A[i].se << '\n';
    FOR(i, 1, N){
        A[i].se += A[i - 1].se;
        mx = max(A[i].fi - A[i - 1].se, mx);
        ans = max(A[i].se - A[i].fi + mx, ans);
        cerr << i << ' ' << A[i].fi << ' ' << A[i].se << ' ' << mx << ' ' << 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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8280 KB Output is correct
2 Correct 3 ms 8280 KB Output is correct
3 Correct 4 ms 8264 KB Output is correct
4 Correct 4 ms 8284 KB Output is correct
5 Correct 4 ms 8284 KB Output is correct
6 Correct 3 ms 8284 KB Output is correct
7 Correct 3 ms 8284 KB Output is correct
8 Correct 3 ms 8284 KB Output is correct
9 Correct 6 ms 8284 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 3 ms 8284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8280 KB Output is correct
2 Correct 3 ms 8280 KB Output is correct
3 Correct 4 ms 8264 KB Output is correct
4 Correct 4 ms 8284 KB Output is correct
5 Correct 4 ms 8284 KB Output is correct
6 Correct 3 ms 8284 KB Output is correct
7 Correct 3 ms 8284 KB Output is correct
8 Correct 3 ms 8284 KB Output is correct
9 Correct 6 ms 8284 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 3 ms 8284 KB Output is correct
12 Correct 8 ms 8280 KB Output is correct
13 Correct 8 ms 8328 KB Output is correct
14 Correct 8 ms 8284 KB Output is correct
15 Correct 8 ms 8300 KB Output is correct
16 Correct 8 ms 8284 KB Output is correct
17 Correct 8 ms 8312 KB Output is correct
18 Correct 8 ms 8284 KB Output is correct
19 Correct 8 ms 8140 KB Output is correct
20 Correct 8 ms 8280 KB Output is correct
21 Correct 10 ms 8284 KB Output is correct
22 Correct 8 ms 8284 KB Output is correct
23 Correct 8 ms 8280 KB Output is correct
24 Correct 8 ms 8284 KB Output is correct
25 Correct 8 ms 8280 KB Output is correct
26 Correct 9 ms 8316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8280 KB Output is correct
2 Correct 3 ms 8280 KB Output is correct
3 Correct 4 ms 8264 KB Output is correct
4 Correct 4 ms 8284 KB Output is correct
5 Correct 4 ms 8284 KB Output is correct
6 Correct 3 ms 8284 KB Output is correct
7 Correct 3 ms 8284 KB Output is correct
8 Correct 3 ms 8284 KB Output is correct
9 Correct 6 ms 8284 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 3 ms 8284 KB Output is correct
12 Correct 8 ms 8280 KB Output is correct
13 Correct 8 ms 8328 KB Output is correct
14 Correct 8 ms 8284 KB Output is correct
15 Correct 8 ms 8300 KB Output is correct
16 Correct 8 ms 8284 KB Output is correct
17 Correct 8 ms 8312 KB Output is correct
18 Correct 8 ms 8284 KB Output is correct
19 Correct 8 ms 8140 KB Output is correct
20 Correct 8 ms 8280 KB Output is correct
21 Correct 10 ms 8284 KB Output is correct
22 Correct 8 ms 8284 KB Output is correct
23 Correct 8 ms 8280 KB Output is correct
24 Correct 8 ms 8284 KB Output is correct
25 Correct 8 ms 8280 KB Output is correct
26 Correct 9 ms 8316 KB Output is correct
27 Correct 85 ms 8688 KB Output is correct
28 Correct 86 ms 8788 KB Output is correct
29 Correct 90 ms 8788 KB Output is correct
30 Correct 84 ms 8728 KB Output is correct
31 Correct 83 ms 8788 KB Output is correct
32 Correct 92 ms 8784 KB Output is correct
33 Correct 84 ms 8788 KB Output is correct
34 Correct 94 ms 8788 KB Output is correct
35 Correct 91 ms 8788 KB Output is correct
36 Correct 85 ms 8740 KB Output is correct
37 Correct 84 ms 8784 KB Output is correct
38 Correct 83 ms 8784 KB Output is correct
39 Correct 84 ms 8788 KB Output is correct
40 Correct 84 ms 8848 KB Output is correct
41 Correct 84 ms 8784 KB Output is correct
42 Correct 85 ms 8788 KB Output is correct
43 Correct 83 ms 8708 KB Output is correct
44 Correct 84 ms 8784 KB Output is correct
45 Correct 83 ms 8756 KB Output is correct
46 Correct 86 ms 8668 KB Output is correct
47 Correct 83 ms 8784 KB Output is correct
48 Correct 85 ms 8784 KB Output is correct
49 Correct 85 ms 8788 KB Output is correct
50 Correct 84 ms 8672 KB Output is correct
51 Correct 84 ms 8784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8280 KB Output is correct
2 Correct 3 ms 8280 KB Output is correct
3 Correct 4 ms 8264 KB Output is correct
4 Correct 4 ms 8284 KB Output is correct
5 Correct 4 ms 8284 KB Output is correct
6 Correct 3 ms 8284 KB Output is correct
7 Correct 3 ms 8284 KB Output is correct
8 Correct 3 ms 8284 KB Output is correct
9 Correct 6 ms 8284 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 3 ms 8284 KB Output is correct
12 Correct 8 ms 8280 KB Output is correct
13 Correct 8 ms 8328 KB Output is correct
14 Correct 8 ms 8284 KB Output is correct
15 Correct 8 ms 8300 KB Output is correct
16 Correct 8 ms 8284 KB Output is correct
17 Correct 8 ms 8312 KB Output is correct
18 Correct 8 ms 8284 KB Output is correct
19 Correct 8 ms 8140 KB Output is correct
20 Correct 8 ms 8280 KB Output is correct
21 Correct 10 ms 8284 KB Output is correct
22 Correct 8 ms 8284 KB Output is correct
23 Correct 8 ms 8280 KB Output is correct
24 Correct 8 ms 8284 KB Output is correct
25 Correct 8 ms 8280 KB Output is correct
26 Correct 9 ms 8316 KB Output is correct
27 Correct 85 ms 8688 KB Output is correct
28 Correct 86 ms 8788 KB Output is correct
29 Correct 90 ms 8788 KB Output is correct
30 Correct 84 ms 8728 KB Output is correct
31 Correct 83 ms 8788 KB Output is correct
32 Correct 92 ms 8784 KB Output is correct
33 Correct 84 ms 8788 KB Output is correct
34 Correct 94 ms 8788 KB Output is correct
35 Correct 91 ms 8788 KB Output is correct
36 Correct 85 ms 8740 KB Output is correct
37 Correct 84 ms 8784 KB Output is correct
38 Correct 83 ms 8784 KB Output is correct
39 Correct 84 ms 8788 KB Output is correct
40 Correct 84 ms 8848 KB Output is correct
41 Correct 84 ms 8784 KB Output is correct
42 Correct 85 ms 8788 KB Output is correct
43 Correct 83 ms 8708 KB Output is correct
44 Correct 84 ms 8784 KB Output is correct
45 Correct 83 ms 8756 KB Output is correct
46 Correct 86 ms 8668 KB Output is correct
47 Correct 83 ms 8784 KB Output is correct
48 Correct 85 ms 8784 KB Output is correct
49 Correct 85 ms 8788 KB Output is correct
50 Correct 84 ms 8672 KB Output is correct
51 Correct 84 ms 8784 KB Output is correct
52 Execution timed out 1041 ms 25416 KB Time limit exceeded
53 Halted 0 ms 0 KB -