답안 #669848

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
669848 2022-12-07T13:34:08 Z raysh07 Art Exhibition (JOI18_art) C++17
100 / 100
215 ms 24972 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void Solve() 
{
    int n;
    cin>>n;
    
    vector <pair<int, int>> v;
    int ma = 0;
    for (int i=0; i<n; i++)
    {
        int m, t;
        cin>>m>>t;
        v.push_back({m, t});
        ma = max(ma, t);
    }
    sort(v.begin(), v.end());
    int psum[n+1];
    psum[0] = 0;
    for (int i=1; i<=n; i++)
    {
        psum[i] = psum[i-1] + v[i-1].second;
    }
    
    //int ma = -1e9;
    int mi = 1e18;
    int pos = 0;
    for (int i=0; i<n; i++)
    {
        int v2 = psum[i]-v[i].first;
        int v1 = psum[i+1] - v[i].first;
        ma = max(ma, v1-mi);
        mi = min(mi, v2);
    }
    cout<<ma<<"\n";
}

int32_t main() 
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++) 
    {
        //cout << "Case #" << i << ": ";
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
    return 0;
}

Compilation message

art.cpp: In function 'void Solve()':
art.cpp:31:9: warning: unused variable 'pos' [-Wunused-variable]
   31 |     int pos = 0;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 ms 596 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 3 ms 640 KB Output is correct
30 Correct 2 ms 648 KB Output is correct
31 Correct 2 ms 656 KB Output is correct
32 Correct 4 ms 580 KB Output is correct
33 Correct 4 ms 592 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 2 ms 596 KB Output is correct
36 Correct 4 ms 596 KB Output is correct
37 Correct 3 ms 596 KB Output is correct
38 Correct 3 ms 724 KB Output is correct
39 Correct 3 ms 644 KB Output is correct
40 Correct 2 ms 576 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 2 ms 648 KB Output is correct
43 Correct 3 ms 596 KB Output is correct
44 Correct 2 ms 596 KB Output is correct
45 Correct 3 ms 596 KB Output is correct
46 Correct 2 ms 596 KB Output is correct
47 Correct 2 ms 664 KB Output is correct
48 Correct 2 ms 592 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
50 Correct 4 ms 596 KB Output is correct
51 Correct 5 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 ms 596 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 3 ms 640 KB Output is correct
30 Correct 2 ms 648 KB Output is correct
31 Correct 2 ms 656 KB Output is correct
32 Correct 4 ms 580 KB Output is correct
33 Correct 4 ms 592 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 2 ms 596 KB Output is correct
36 Correct 4 ms 596 KB Output is correct
37 Correct 3 ms 596 KB Output is correct
38 Correct 3 ms 724 KB Output is correct
39 Correct 3 ms 644 KB Output is correct
40 Correct 2 ms 576 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 2 ms 648 KB Output is correct
43 Correct 3 ms 596 KB Output is correct
44 Correct 2 ms 596 KB Output is correct
45 Correct 3 ms 596 KB Output is correct
46 Correct 2 ms 596 KB Output is correct
47 Correct 2 ms 664 KB Output is correct
48 Correct 2 ms 592 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
50 Correct 4 ms 596 KB Output is correct
51 Correct 5 ms 596 KB Output is correct
52 Correct 213 ms 24680 KB Output is correct
53 Correct 198 ms 24744 KB Output is correct
54 Correct 200 ms 24784 KB Output is correct
55 Correct 181 ms 24772 KB Output is correct
56 Correct 215 ms 24700 KB Output is correct
57 Correct 188 ms 24940 KB Output is correct
58 Correct 205 ms 24768 KB Output is correct
59 Correct 189 ms 24780 KB Output is correct
60 Correct 202 ms 24796 KB Output is correct
61 Correct 172 ms 24756 KB Output is correct
62 Correct 180 ms 24792 KB Output is correct
63 Correct 187 ms 24764 KB Output is correct
64 Correct 178 ms 24876 KB Output is correct
65 Correct 174 ms 24844 KB Output is correct
66 Correct 173 ms 24760 KB Output is correct
67 Correct 175 ms 24972 KB Output is correct
68 Correct 168 ms 24788 KB Output is correct