답안 #78688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
78688 2018-10-07T14:26:48 Z Saboon Art Exhibition (JOI18_art) C++14
100 / 100
285 ms 79644 KB
#include <iostream>
#include <queue>
#include <bitset>
#include <stack>
#include <vector>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef unsigned long long ull;

const int maxn = 5e5 + 100;
const int INF = 1e5;

pair <ll, ll> p[maxn];
ll dp[maxn];

int main (){
    ios_base::sync_with_stdio (false);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> p[i].F >> p[i].S;
    sort (p + 1, p + n + 1);
    dp[0] = -INF;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        dp[i] = p[i].S;
        dp[i] = max (dp[i], dp[i - 1] - p[i].F + p[i - 1].F + p[i].S);
        ans = max (ans, dp[i]);
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 2 ms 540 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 3 ms 616 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 3 ms 652 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 2 ms 540 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 3 ms 616 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 3 ms 652 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 2 ms 660 KB Output is correct
13 Correct 2 ms 924 KB Output is correct
14 Correct 2 ms 924 KB Output is correct
15 Correct 2 ms 924 KB Output is correct
16 Correct 2 ms 924 KB Output is correct
17 Correct 2 ms 924 KB Output is correct
18 Correct 3 ms 924 KB Output is correct
19 Correct 2 ms 924 KB Output is correct
20 Correct 2 ms 924 KB Output is correct
21 Correct 2 ms 924 KB Output is correct
22 Correct 2 ms 924 KB Output is correct
23 Correct 3 ms 924 KB Output is correct
24 Correct 3 ms 924 KB Output is correct
25 Correct 2 ms 924 KB Output is correct
26 Correct 3 ms 924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 2 ms 540 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 3 ms 616 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 3 ms 652 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 2 ms 660 KB Output is correct
13 Correct 2 ms 924 KB Output is correct
14 Correct 2 ms 924 KB Output is correct
15 Correct 2 ms 924 KB Output is correct
16 Correct 2 ms 924 KB Output is correct
17 Correct 2 ms 924 KB Output is correct
18 Correct 3 ms 924 KB Output is correct
19 Correct 2 ms 924 KB Output is correct
20 Correct 2 ms 924 KB Output is correct
21 Correct 2 ms 924 KB Output is correct
22 Correct 2 ms 924 KB Output is correct
23 Correct 3 ms 924 KB Output is correct
24 Correct 3 ms 924 KB Output is correct
25 Correct 2 ms 924 KB Output is correct
26 Correct 3 ms 924 KB Output is correct
27 Correct 6 ms 1052 KB Output is correct
28 Correct 4 ms 1180 KB Output is correct
29 Correct 6 ms 1308 KB Output is correct
30 Correct 5 ms 1424 KB Output is correct
31 Correct 5 ms 1724 KB Output is correct
32 Correct 5 ms 1724 KB Output is correct
33 Correct 6 ms 1820 KB Output is correct
34 Correct 4 ms 1948 KB Output is correct
35 Correct 6 ms 2076 KB Output is correct
36 Correct 6 ms 2204 KB Output is correct
37 Correct 4 ms 2332 KB Output is correct
38 Correct 4 ms 2460 KB Output is correct
39 Correct 6 ms 2588 KB Output is correct
40 Correct 5 ms 2716 KB Output is correct
41 Correct 6 ms 2824 KB Output is correct
42 Correct 6 ms 2972 KB Output is correct
43 Correct 6 ms 3096 KB Output is correct
44 Correct 6 ms 3224 KB Output is correct
45 Correct 5 ms 3352 KB Output is correct
46 Correct 4 ms 3480 KB Output is correct
47 Correct 6 ms 3608 KB Output is correct
48 Correct 4 ms 3736 KB Output is correct
49 Correct 6 ms 3864 KB Output is correct
50 Correct 6 ms 3992 KB Output is correct
51 Correct 4 ms 4120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 2 ms 540 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 3 ms 616 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 3 ms 652 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 2 ms 660 KB Output is correct
13 Correct 2 ms 924 KB Output is correct
14 Correct 2 ms 924 KB Output is correct
15 Correct 2 ms 924 KB Output is correct
16 Correct 2 ms 924 KB Output is correct
17 Correct 2 ms 924 KB Output is correct
18 Correct 3 ms 924 KB Output is correct
19 Correct 2 ms 924 KB Output is correct
20 Correct 2 ms 924 KB Output is correct
21 Correct 2 ms 924 KB Output is correct
22 Correct 2 ms 924 KB Output is correct
23 Correct 3 ms 924 KB Output is correct
24 Correct 3 ms 924 KB Output is correct
25 Correct 2 ms 924 KB Output is correct
26 Correct 3 ms 924 KB Output is correct
27 Correct 6 ms 1052 KB Output is correct
28 Correct 4 ms 1180 KB Output is correct
29 Correct 6 ms 1308 KB Output is correct
30 Correct 5 ms 1424 KB Output is correct
31 Correct 5 ms 1724 KB Output is correct
32 Correct 5 ms 1724 KB Output is correct
33 Correct 6 ms 1820 KB Output is correct
34 Correct 4 ms 1948 KB Output is correct
35 Correct 6 ms 2076 KB Output is correct
36 Correct 6 ms 2204 KB Output is correct
37 Correct 4 ms 2332 KB Output is correct
38 Correct 4 ms 2460 KB Output is correct
39 Correct 6 ms 2588 KB Output is correct
40 Correct 5 ms 2716 KB Output is correct
41 Correct 6 ms 2824 KB Output is correct
42 Correct 6 ms 2972 KB Output is correct
43 Correct 6 ms 3096 KB Output is correct
44 Correct 6 ms 3224 KB Output is correct
45 Correct 5 ms 3352 KB Output is correct
46 Correct 4 ms 3480 KB Output is correct
47 Correct 6 ms 3608 KB Output is correct
48 Correct 4 ms 3736 KB Output is correct
49 Correct 6 ms 3864 KB Output is correct
50 Correct 6 ms 3992 KB Output is correct
51 Correct 4 ms 4120 KB Output is correct
52 Correct 251 ms 28336 KB Output is correct
53 Correct 243 ms 40884 KB Output is correct
54 Correct 240 ms 53516 KB Output is correct
55 Correct 251 ms 66356 KB Output is correct
56 Correct 257 ms 78960 KB Output is correct
57 Correct 237 ms 79540 KB Output is correct
58 Correct 236 ms 79608 KB Output is correct
59 Correct 239 ms 79608 KB Output is correct
60 Correct 237 ms 79608 KB Output is correct
61 Correct 246 ms 79608 KB Output is correct
62 Correct 285 ms 79608 KB Output is correct
63 Correct 255 ms 79644 KB Output is correct
64 Correct 253 ms 79644 KB Output is correct
65 Correct 237 ms 79644 KB Output is correct
66 Correct 243 ms 79644 KB Output is correct
67 Correct 240 ms 79644 KB Output is correct
68 Correct 238 ms 79644 KB Output is correct