# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
81562 | 2018-10-25T10:27:16 Z | farukkastamonuda | Art Exhibition (JOI18_art) | C++14 | 456 ms | 243044 KB |
#include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000009 #define md 1000000007 #define li 500005 #define mp make_pair #define pb push_back using namespace std; int n,flag; lo int val,mx; pair<lo int,lo int> p[li]; vector< pair<lo int,lo int> > v; priority_queue< pair<lo int,lo int> > q; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld %lld",&p[i].fi,&p[i].se); } sort(p+1,p+n+1); for(int i=1;i<=n;i++){ val+=p[i].se; lo int val2=p[i].se; while(i<n && p[i+1].fi==p[i].fi){ val+=p[i+1].se; val2+=p[i+1].se; i++; } v.push_back(mp(p[i].fi,val)); mx=max(mx,val-(p[i].fi-p[1].fi)); q.push(mp(val-(p[i].fi-p[1].fi),p[i].fi)); } for(int i=0;i<(int)v.size();i++){ if(i==0) continue; lo int go=v[i].fi; //int deg=v[i].se; lo int extra=-v[i-1].se+go-v[0].fi; while(!q.empty()){ pair<lo int,lo int> temp=q.top(); q.pop(); if(temp.se<go) continue; mx=max(mx,temp.fi+extra); q.push(temp); //q.push(mp(temp.fi+extra,go)); break; } } printf("%lld\n",mx); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 2 ms | 476 KB | Output is correct |
4 | Correct | 2 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 2 ms | 532 KB | Output is correct |
7 | Correct | 2 ms | 708 KB | Output is correct |
8 | Correct | 2 ms | 708 KB | Output is correct |
9 | Correct | 2 ms | 708 KB | Output is correct |
10 | Correct | 2 ms | 748 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 2 ms | 476 KB | Output is correct |
4 | Correct | 2 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 2 ms | 532 KB | Output is correct |
7 | Correct | 2 ms | 708 KB | Output is correct |
8 | Correct | 2 ms | 708 KB | Output is correct |
9 | Correct | 2 ms | 708 KB | Output is correct |
10 | Correct | 2 ms | 748 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
15 | Correct | 2 ms | 748 KB | Output is correct |
16 | Correct | 2 ms | 756 KB | Output is correct |
17 | Correct | 2 ms | 764 KB | Output is correct |
18 | Correct | 2 ms | 772 KB | Output is correct |
19 | Correct | 2 ms | 784 KB | Output is correct |
20 | Correct | 2 ms | 788 KB | Output is correct |
21 | Correct | 2 ms | 796 KB | Output is correct |
22 | Correct | 2 ms | 820 KB | Output is correct |
23 | Correct | 2 ms | 924 KB | Output is correct |
24 | Correct | 2 ms | 924 KB | Output is correct |
25 | Correct | 3 ms | 924 KB | Output is correct |
26 | Correct | 2 ms | 924 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 2 ms | 476 KB | Output is correct |
4 | Correct | 2 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 2 ms | 532 KB | Output is correct |
7 | Correct | 2 ms | 708 KB | Output is correct |
8 | Correct | 2 ms | 708 KB | Output is correct |
9 | Correct | 2 ms | 708 KB | Output is correct |
10 | Correct | 2 ms | 748 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
15 | Correct | 2 ms | 748 KB | Output is correct |
16 | Correct | 2 ms | 756 KB | Output is correct |
17 | Correct | 2 ms | 764 KB | Output is correct |
18 | Correct | 2 ms | 772 KB | Output is correct |
19 | Correct | 2 ms | 784 KB | Output is correct |
20 | Correct | 2 ms | 788 KB | Output is correct |
21 | Correct | 2 ms | 796 KB | Output is correct |
22 | Correct | 2 ms | 820 KB | Output is correct |
23 | Correct | 2 ms | 924 KB | Output is correct |
24 | Correct | 2 ms | 924 KB | Output is correct |
25 | Correct | 3 ms | 924 KB | Output is correct |
26 | Correct | 2 ms | 924 KB | Output is correct |
27 | Correct | 6 ms | 1276 KB | Output is correct |
28 | Correct | 8 ms | 1372 KB | Output is correct |
29 | Correct | 5 ms | 1500 KB | Output is correct |
30 | Correct | 6 ms | 1628 KB | Output is correct |
31 | Correct | 5 ms | 1756 KB | Output is correct |
32 | Correct | 5 ms | 1892 KB | Output is correct |
33 | Correct | 6 ms | 2012 KB | Output is correct |
34 | Correct | 5 ms | 2276 KB | Output is correct |
35 | Correct | 5 ms | 2276 KB | Output is correct |
36 | Correct | 5 ms | 2396 KB | Output is correct |
37 | Correct | 5 ms | 2524 KB | Output is correct |
38 | Correct | 5 ms | 2652 KB | Output is correct |
39 | Correct | 5 ms | 2800 KB | Output is correct |
40 | Correct | 7 ms | 2908 KB | Output is correct |
41 | Correct | 6 ms | 3036 KB | Output is correct |
42 | Correct | 5 ms | 3160 KB | Output is correct |
43 | Correct | 5 ms | 3324 KB | Output is correct |
44 | Correct | 5 ms | 3488 KB | Output is correct |
45 | Correct | 5 ms | 3544 KB | Output is correct |
46 | Correct | 5 ms | 3708 KB | Output is correct |
47 | Correct | 5 ms | 3800 KB | Output is correct |
48 | Correct | 5 ms | 3928 KB | Output is correct |
49 | Correct | 5 ms | 4056 KB | Output is correct |
50 | Correct | 5 ms | 4184 KB | Output is correct |
51 | Correct | 5 ms | 4348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 2 ms | 476 KB | Output is correct |
4 | Correct | 2 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 2 ms | 532 KB | Output is correct |
7 | Correct | 2 ms | 708 KB | Output is correct |
8 | Correct | 2 ms | 708 KB | Output is correct |
9 | Correct | 2 ms | 708 KB | Output is correct |
10 | Correct | 2 ms | 748 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
15 | Correct | 2 ms | 748 KB | Output is correct |
16 | Correct | 2 ms | 756 KB | Output is correct |
17 | Correct | 2 ms | 764 KB | Output is correct |
18 | Correct | 2 ms | 772 KB | Output is correct |
19 | Correct | 2 ms | 784 KB | Output is correct |
20 | Correct | 2 ms | 788 KB | Output is correct |
21 | Correct | 2 ms | 796 KB | Output is correct |
22 | Correct | 2 ms | 820 KB | Output is correct |
23 | Correct | 2 ms | 924 KB | Output is correct |
24 | Correct | 2 ms | 924 KB | Output is correct |
25 | Correct | 3 ms | 924 KB | Output is correct |
26 | Correct | 2 ms | 924 KB | Output is correct |
27 | Correct | 6 ms | 1276 KB | Output is correct |
28 | Correct | 8 ms | 1372 KB | Output is correct |
29 | Correct | 5 ms | 1500 KB | Output is correct |
30 | Correct | 6 ms | 1628 KB | Output is correct |
31 | Correct | 5 ms | 1756 KB | Output is correct |
32 | Correct | 5 ms | 1892 KB | Output is correct |
33 | Correct | 6 ms | 2012 KB | Output is correct |
34 | Correct | 5 ms | 2276 KB | Output is correct |
35 | Correct | 5 ms | 2276 KB | Output is correct |
36 | Correct | 5 ms | 2396 KB | Output is correct |
37 | Correct | 5 ms | 2524 KB | Output is correct |
38 | Correct | 5 ms | 2652 KB | Output is correct |
39 | Correct | 5 ms | 2800 KB | Output is correct |
40 | Correct | 7 ms | 2908 KB | Output is correct |
41 | Correct | 6 ms | 3036 KB | Output is correct |
42 | Correct | 5 ms | 3160 KB | Output is correct |
43 | Correct | 5 ms | 3324 KB | Output is correct |
44 | Correct | 5 ms | 3488 KB | Output is correct |
45 | Correct | 5 ms | 3544 KB | Output is correct |
46 | Correct | 5 ms | 3708 KB | Output is correct |
47 | Correct | 5 ms | 3800 KB | Output is correct |
48 | Correct | 5 ms | 3928 KB | Output is correct |
49 | Correct | 5 ms | 4056 KB | Output is correct |
50 | Correct | 5 ms | 4184 KB | Output is correct |
51 | Correct | 5 ms | 4348 KB | Output is correct |
52 | Correct | 429 ms | 40244 KB | Output is correct |
53 | Correct | 430 ms | 53076 KB | Output is correct |
54 | Correct | 432 ms | 65720 KB | Output is correct |
55 | Correct | 401 ms | 78416 KB | Output is correct |
56 | Correct | 456 ms | 90980 KB | Output is correct |
57 | Correct | 418 ms | 103796 KB | Output is correct |
58 | Correct | 368 ms | 116308 KB | Output is correct |
59 | Correct | 345 ms | 129208 KB | Output is correct |
60 | Correct | 363 ms | 141756 KB | Output is correct |
61 | Correct | 343 ms | 154188 KB | Output is correct |
62 | Correct | 342 ms | 166888 KB | Output is correct |
63 | Correct | 351 ms | 179532 KB | Output is correct |
64 | Correct | 361 ms | 192400 KB | Output is correct |
65 | Correct | 367 ms | 204984 KB | Output is correct |
66 | Correct | 370 ms | 217716 KB | Output is correct |
67 | Correct | 351 ms | 230376 KB | Output is correct |
68 | Correct | 360 ms | 243044 KB | Output is correct |