답안 #217701

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217701 2020-03-30T13:16:47 Z VEGAnn 새 집 (APIO18_new_home) C++14
12 / 100
2044 ms 27336 KB
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define PB push_back
#define pii pair<int,int>
#define ft first
#define sd second
#define MP make_pair
#define MP3(a,b,c) MP(MP(a,b),c)
#define pi3 pair<pii,int>
using namespace std;
typedef long long ll;
const int N = 300100;
const int M = 200100;
const int K = 410;
const int oo = 2e9;
vector<pi3> qr;
multiset<int> st[K];
multiset<int>::iterator ite;
int ans[N], n, k, q;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

//    freopen("in.txt","r",stdin);

    cin >> n >> k >> q;

    for (int i = 0; i < n; i++){
        int x, t, a, b;
        cin >> x >> t >> a >> b;

        qr.PB(MP3(a, -t, x));
        qr.PB(MP3(b + 1, -t, -x));
    }

    for (int i = 0; i < q; i++){
        int y, l; cin >> l >> y;
        qr.PB(MP3(y, l, i));
    }

    sort(all(qr));

    for (pi3 cr : qr)
        if (cr.ft.sd < 0){
            int tp = -cr.ft.sd;

            if (cr.sd < 0)
                st[tp].erase(st[tp].find(-cr.sd));
            else st[tp].insert(cr.sd);
        } else {

            int res = 0;

            for (int tp = 1; tp <= k; tp++){
                if (!sz(st[tp])){
                    res = oo;
                    break;
                }

                int cur = oo;

                ite = st[tp].upper_bound(cr.ft.sd);

                if (ite != st[tp].end())
                    cur = min(cur, (*ite) - cr.ft.sd);

                if (ite != st[tp].begin())
                    cur = min(cur, cr.ft.sd - (*prev(ite)));

                res = max(res, cur);
            }

            ans[cr.sd] = (res == oo ? -1 : res);
        }

    for (int i = 0; i < q; i++)
        cout << ans[i] << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 2044 ms 6656 KB Output is correct
32 Correct 76 ms 4964 KB Output is correct
33 Correct 182 ms 7008 KB Output is correct
34 Correct 1596 ms 7388 KB Output is correct
35 Correct 926 ms 8928 KB Output is correct
36 Correct 203 ms 8804 KB Output is correct
37 Correct 179 ms 6284 KB Output is correct
38 Correct 109 ms 6116 KB Output is correct
39 Correct 95 ms 6116 KB Output is correct
40 Correct 96 ms 5988 KB Output is correct
41 Correct 280 ms 6368 KB Output is correct
42 Correct 217 ms 6116 KB Output is correct
43 Correct 635 ms 8528 KB Output is correct
44 Correct 232 ms 6364 KB Output is correct
45 Correct 130 ms 6368 KB Output is correct
46 Correct 84 ms 6316 KB Output is correct
47 Correct 74 ms 5860 KB Output is correct
48 Correct 71 ms 5856 KB Output is correct
49 Correct 87 ms 5988 KB Output is correct
50 Correct 190 ms 6116 KB Output is correct
51 Correct 82 ms 5988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 339 ms 27336 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 327 ms 27336 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 2044 ms 6656 KB Output is correct
32 Correct 76 ms 4964 KB Output is correct
33 Correct 182 ms 7008 KB Output is correct
34 Correct 1596 ms 7388 KB Output is correct
35 Correct 926 ms 8928 KB Output is correct
36 Correct 203 ms 8804 KB Output is correct
37 Correct 179 ms 6284 KB Output is correct
38 Correct 109 ms 6116 KB Output is correct
39 Correct 95 ms 6116 KB Output is correct
40 Correct 96 ms 5988 KB Output is correct
41 Correct 280 ms 6368 KB Output is correct
42 Correct 217 ms 6116 KB Output is correct
43 Correct 635 ms 8528 KB Output is correct
44 Correct 232 ms 6364 KB Output is correct
45 Correct 130 ms 6368 KB Output is correct
46 Correct 84 ms 6316 KB Output is correct
47 Correct 74 ms 5860 KB Output is correct
48 Correct 71 ms 5856 KB Output is correct
49 Correct 87 ms 5988 KB Output is correct
50 Correct 190 ms 6116 KB Output is correct
51 Correct 82 ms 5988 KB Output is correct
52 Runtime error 72 ms 8164 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 2044 ms 6656 KB Output is correct
32 Correct 76 ms 4964 KB Output is correct
33 Correct 182 ms 7008 KB Output is correct
34 Correct 1596 ms 7388 KB Output is correct
35 Correct 926 ms 8928 KB Output is correct
36 Correct 203 ms 8804 KB Output is correct
37 Correct 179 ms 6284 KB Output is correct
38 Correct 109 ms 6116 KB Output is correct
39 Correct 95 ms 6116 KB Output is correct
40 Correct 96 ms 5988 KB Output is correct
41 Correct 280 ms 6368 KB Output is correct
42 Correct 217 ms 6116 KB Output is correct
43 Correct 635 ms 8528 KB Output is correct
44 Correct 232 ms 6364 KB Output is correct
45 Correct 130 ms 6368 KB Output is correct
46 Correct 84 ms 6316 KB Output is correct
47 Correct 74 ms 5860 KB Output is correct
48 Correct 71 ms 5856 KB Output is correct
49 Correct 87 ms 5988 KB Output is correct
50 Correct 190 ms 6116 KB Output is correct
51 Correct 82 ms 5988 KB Output is correct
52 Runtime error 339 ms 27336 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Halted 0 ms 0 KB -