답안 #868917

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
868917 2023-11-02T12:29:02 Z rockstar Art Exhibition (JOI18_art) C++17
100 / 100
236 ms 44620 KB
// #pragma GCC optimize("O3,unroll-loops,inline,no-stack-protector")
// #pragma GCC target("avx,avx2,sse3,ssse3,sse4.1,sse4.2,fma,bmi2,abm,popcnt,mmx,tune=native")

#include <bits/stdc++.h>

using namespace std;

#define trace(x) cerr << #x << ": " << (x) << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;

#define int ll

constexpr int INF = numeric_limits<int>::max() / 2;

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (auto& i : v)
        cin >> i.first >> i.second;
    sort(all(v));
    set<int> st;
    int ans = 0, pref = 0;
    for (int i = 0; i < n; ++i) {
        st.insert(pref - v[i].first);
        pref += v[i].second;
        ans = max(ans, pref - v[i].first - *st.begin());
    }
    cout << ans;
}

signed main() {
#ifdef LOCAL
    freopen("input.in", "r", stdin);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
#ifdef LOCAL
    cerr << '\n' << "time = " << clock() * 1.0 / CLOCKS_PER_SEC << '\n';
#endif
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 412 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 412 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 2 ms 860 KB Output is correct
28 Correct 2 ms 860 KB Output is correct
29 Correct 2 ms 860 KB Output is correct
30 Correct 2 ms 652 KB Output is correct
31 Correct 2 ms 860 KB Output is correct
32 Correct 2 ms 860 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 3 ms 856 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 2 ms 860 KB Output is correct
37 Correct 2 ms 860 KB Output is correct
38 Correct 2 ms 724 KB Output is correct
39 Correct 2 ms 860 KB Output is correct
40 Correct 3 ms 856 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 2 ms 636 KB Output is correct
43 Correct 2 ms 856 KB Output is correct
44 Correct 2 ms 860 KB Output is correct
45 Correct 2 ms 856 KB Output is correct
46 Correct 2 ms 860 KB Output is correct
47 Correct 2 ms 672 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 860 KB Output is correct
50 Correct 2 ms 664 KB Output is correct
51 Correct 2 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 412 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 2 ms 860 KB Output is correct
28 Correct 2 ms 860 KB Output is correct
29 Correct 2 ms 860 KB Output is correct
30 Correct 2 ms 652 KB Output is correct
31 Correct 2 ms 860 KB Output is correct
32 Correct 2 ms 860 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 3 ms 856 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 2 ms 860 KB Output is correct
37 Correct 2 ms 860 KB Output is correct
38 Correct 2 ms 724 KB Output is correct
39 Correct 2 ms 860 KB Output is correct
40 Correct 3 ms 856 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 2 ms 636 KB Output is correct
43 Correct 2 ms 856 KB Output is correct
44 Correct 2 ms 860 KB Output is correct
45 Correct 2 ms 856 KB Output is correct
46 Correct 2 ms 860 KB Output is correct
47 Correct 2 ms 672 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 860 KB Output is correct
50 Correct 2 ms 664 KB Output is correct
51 Correct 2 ms 856 KB Output is correct
52 Correct 195 ms 44360 KB Output is correct
53 Correct 198 ms 44372 KB Output is correct
54 Correct 201 ms 44372 KB Output is correct
55 Correct 210 ms 44356 KB Output is correct
56 Correct 214 ms 44364 KB Output is correct
57 Correct 225 ms 44232 KB Output is correct
58 Correct 199 ms 44224 KB Output is correct
59 Correct 199 ms 44288 KB Output is correct
60 Correct 202 ms 44352 KB Output is correct
61 Correct 200 ms 44116 KB Output is correct
62 Correct 197 ms 44184 KB Output is correct
63 Correct 204 ms 44620 KB Output is correct
64 Correct 199 ms 44348 KB Output is correct
65 Correct 218 ms 44372 KB Output is correct
66 Correct 195 ms 44352 KB Output is correct
67 Correct 193 ms 44372 KB Output is correct
68 Correct 236 ms 44372 KB Output is correct