답안 #715765

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715765 2023-03-27T19:44:08 Z ovidiush11 Art Exhibition (JOI18_art) C++14
100 / 100
571 ms 24176 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main()
{
    ll n;
    cin>>n;
    vector<pair<ll,ll>> a(n);
    for(ll i = 0;i < n;i++)cin>>a[i].first>>a[i].second;
    sort(a.begin(),a.end());
    a.push_back({1e15+1,0});
    vector<pair<ll,ll>> v;
    for(ll i = 0;i < n;i++)
    {
        if(a[i].first == a[i+1].first)a[i+1].second += a[i].second;
        else v.push_back(a[i]);
    }
    n = v.size();
    vector<pair<ll,ll>> p(n);
    p[0] = {v[0].second,0ll};
    for(ll i = 1;i < n;i++)p[i] = {p[i-1].first + v[i].second - (v[i].first - v[i-1].first),i};
    sort(p.begin(),p.end(),greater<pair<ll,ll>>());
    ll j = 0,i = 0,ans = 0,k = 0;
    while(i < n)
    {
        ll mx,pos;
        while(p[j].second < i)j++;
        mx = p[j].first;pos = p[j].second;
        ans = max(ans,mx+k);
        for(i = i+1;i <= pos;i++)
        {
            k += v[i].first - v[i-1].first - v[i-1].second;
            ans = max(ans,mx+k);
        }
        k += v[i].first - v[i-1].first - v[i-1].second;
    }
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 284 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 284 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 284 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 5 ms 468 KB Output is correct
28 Correct 6 ms 596 KB Output is correct
29 Correct 5 ms 596 KB Output is correct
30 Correct 6 ms 468 KB Output is correct
31 Correct 5 ms 468 KB Output is correct
32 Correct 6 ms 468 KB Output is correct
33 Correct 6 ms 468 KB Output is correct
34 Correct 5 ms 468 KB Output is correct
35 Correct 6 ms 596 KB Output is correct
36 Correct 6 ms 508 KB Output is correct
37 Correct 7 ms 504 KB Output is correct
38 Correct 6 ms 468 KB Output is correct
39 Correct 5 ms 468 KB Output is correct
40 Correct 6 ms 468 KB Output is correct
41 Correct 6 ms 596 KB Output is correct
42 Correct 6 ms 508 KB Output is correct
43 Correct 7 ms 500 KB Output is correct
44 Correct 6 ms 468 KB Output is correct
45 Correct 6 ms 468 KB Output is correct
46 Correct 6 ms 596 KB Output is correct
47 Correct 5 ms 500 KB Output is correct
48 Correct 6 ms 504 KB Output is correct
49 Correct 6 ms 468 KB Output is correct
50 Correct 6 ms 596 KB Output is correct
51 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 284 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 5 ms 468 KB Output is correct
28 Correct 6 ms 596 KB Output is correct
29 Correct 5 ms 596 KB Output is correct
30 Correct 6 ms 468 KB Output is correct
31 Correct 5 ms 468 KB Output is correct
32 Correct 6 ms 468 KB Output is correct
33 Correct 6 ms 468 KB Output is correct
34 Correct 5 ms 468 KB Output is correct
35 Correct 6 ms 596 KB Output is correct
36 Correct 6 ms 508 KB Output is correct
37 Correct 7 ms 504 KB Output is correct
38 Correct 6 ms 468 KB Output is correct
39 Correct 5 ms 468 KB Output is correct
40 Correct 6 ms 468 KB Output is correct
41 Correct 6 ms 596 KB Output is correct
42 Correct 6 ms 508 KB Output is correct
43 Correct 7 ms 500 KB Output is correct
44 Correct 6 ms 468 KB Output is correct
45 Correct 6 ms 468 KB Output is correct
46 Correct 6 ms 596 KB Output is correct
47 Correct 5 ms 500 KB Output is correct
48 Correct 6 ms 504 KB Output is correct
49 Correct 6 ms 468 KB Output is correct
50 Correct 6 ms 596 KB Output is correct
51 Correct 5 ms 504 KB Output is correct
52 Correct 488 ms 24120 KB Output is correct
53 Correct 495 ms 24120 KB Output is correct
54 Correct 503 ms 24128 KB Output is correct
55 Correct 514 ms 24108 KB Output is correct
56 Correct 521 ms 24124 KB Output is correct
57 Correct 511 ms 24132 KB Output is correct
58 Correct 515 ms 24120 KB Output is correct
59 Correct 508 ms 24176 KB Output is correct
60 Correct 505 ms 24108 KB Output is correct
61 Correct 571 ms 24132 KB Output is correct
62 Correct 513 ms 24144 KB Output is correct
63 Correct 492 ms 24168 KB Output is correct
64 Correct 508 ms 24144 KB Output is correct
65 Correct 491 ms 24080 KB Output is correct
66 Correct 489 ms 24144 KB Output is correct
67 Correct 495 ms 24124 KB Output is correct
68 Correct 495 ms 24108 KB Output is correct