답안 #160379

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
160379 2019-10-27T08:27:26 Z godwind Art Exhibition (JOI18_art) C++14
50 / 100
1000 ms 81124 KB
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
 
 
using namespace std;
 
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
 
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}
 
#define int long long
#define left left228
#define right right228
#define prev prev228
#define list list228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second

const int N = 500 * 1000 + 228;

int a[N], b[N];
int X;

struct node
{
    int mx, mod;
    int l, r;
    node() {
        mx = mod = l = r = 0;
    }
};
vector< node > d;
void build(int l, int r, int v = 1) {
    d[v].l = l, d[v].r = r;
    if (l == r) {
    } else {
        int m = (l + r) >> 1;
        build(l, m, v << 1); build(m + 1, r, v << 1 | 1);
    }
}
int gets(int v) {
    return d[v].mx + d[v].mod;
}
void push(int v) {
    d[v << 1].mod += d[v].mod;
    d[v << 1 | 1].mod += d[v].mod;
    d[v].mod = 0;
    d[v].mx = max(gets(v << 1), gets(v << 1 | 1));
}
void update(int l, int r, int x, int v = 1) {
    if (l > r || d[v].l > r || d[v].r < l) return;
    if (l <= d[v].l && d[v].r <= r) {
        d[v].mod += x;
    } else {
        push(v);
        update(l, r, x, v << 1); update(l, r, x, v << 1 | 1);
        d[v].mx = max(gets(v << 1), gets(v << 1 | 1));
    }
}
int get(int l, int r, int v = 1) {
    if (l > r || d[v].l > r || d[v].r < l) return 0;
    if (l <= d[v].l && d[v].r <= r) return gets(v);
    push(v);
    return max(get(l, r, v << 1), get(l, r, v << 1 | 1));
}
void init(int n) {
    int ss = 1;
    while (ss < n) ss <<= 1;
    ss <<= 1;
    d.resize(ss + 3, node());
    build(1, n);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> crd;
    map<int, int> sum;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i];
        sum[a[i]] += b[i];
        crd.push_back(a[i]);
    }
    sort(crd.begin(), crd.end());
    crd.erase(unique(crd.begin(), crd.end()), crd.end());
    int sz = (int)crd.size();
    init(sz);
    for (int i = 1; i <= sz; ++i) {
        update(i, i, crd.back() - crd[i - 1]);
    }
    int res = 0;
    int pv = crd.back();
    for (int i = sz; i; --i) {
        update(1, sz, crd[i - 1] - pv);
        pv = crd[i - 1];
        update(i, sz, sum[crd[i - 1]]);
        uax(res, get(i, sz));
    }
    cout << res << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 10 ms 1272 KB Output is correct
28 Correct 10 ms 1272 KB Output is correct
29 Correct 10 ms 1272 KB Output is correct
30 Correct 10 ms 1272 KB Output is correct
31 Correct 10 ms 1272 KB Output is correct
32 Correct 10 ms 1272 KB Output is correct
33 Correct 10 ms 1272 KB Output is correct
34 Correct 10 ms 1272 KB Output is correct
35 Correct 10 ms 1400 KB Output is correct
36 Correct 11 ms 1272 KB Output is correct
37 Correct 10 ms 1272 KB Output is correct
38 Correct 10 ms 1272 KB Output is correct
39 Correct 10 ms 1276 KB Output is correct
40 Correct 10 ms 1272 KB Output is correct
41 Correct 10 ms 1272 KB Output is correct
42 Correct 10 ms 1276 KB Output is correct
43 Correct 10 ms 1272 KB Output is correct
44 Correct 10 ms 1272 KB Output is correct
45 Correct 10 ms 1364 KB Output is correct
46 Correct 10 ms 1272 KB Output is correct
47 Correct 10 ms 1272 KB Output is correct
48 Correct 10 ms 1272 KB Output is correct
49 Correct 10 ms 1272 KB Output is correct
50 Correct 10 ms 1272 KB Output is correct
51 Correct 10 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 10 ms 1272 KB Output is correct
28 Correct 10 ms 1272 KB Output is correct
29 Correct 10 ms 1272 KB Output is correct
30 Correct 10 ms 1272 KB Output is correct
31 Correct 10 ms 1272 KB Output is correct
32 Correct 10 ms 1272 KB Output is correct
33 Correct 10 ms 1272 KB Output is correct
34 Correct 10 ms 1272 KB Output is correct
35 Correct 10 ms 1400 KB Output is correct
36 Correct 11 ms 1272 KB Output is correct
37 Correct 10 ms 1272 KB Output is correct
38 Correct 10 ms 1272 KB Output is correct
39 Correct 10 ms 1276 KB Output is correct
40 Correct 10 ms 1272 KB Output is correct
41 Correct 10 ms 1272 KB Output is correct
42 Correct 10 ms 1276 KB Output is correct
43 Correct 10 ms 1272 KB Output is correct
44 Correct 10 ms 1272 KB Output is correct
45 Correct 10 ms 1364 KB Output is correct
46 Correct 10 ms 1272 KB Output is correct
47 Correct 10 ms 1272 KB Output is correct
48 Correct 10 ms 1272 KB Output is correct
49 Correct 10 ms 1272 KB Output is correct
50 Correct 10 ms 1272 KB Output is correct
51 Correct 10 ms 1272 KB Output is correct
52 Execution timed out 1076 ms 81124 KB Time limit exceeded
53 Halted 0 ms 0 KB -