답안 #971567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971567 2024-04-29T01:49:03 Z irmuun 새 집 (APIO18_new_home) C++17
12 / 100
5000 ms 66196 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,k,q;
    cin>>n>>k>>q;
    vector<array<ll,3>>v;//-1 open 0 ask 1 close
    ll x[n+5],t[n+5],a[n+5],b[n+5];
    for(ll i=1;i<=n;i++){
        cin>>x[i]>>t[i]>>a[i]>>b[i];
        v.pb({a[i],-1,i});
        v.pb({b[i],1,i});
    }
    multiset<ll>st[k+5];
    for(ll i=1;i<=k;i++){
        st[i].insert(-1e9);
        st[i].insert(1e9);
    }
    ll l[q+5],y[q+5];
    for(ll i=1;i<=q;i++){
        cin>>l[i]>>y[i];
        v.pb({y[i],0,i});
    }
    sort(all(v));
    ll ans[n+5];
    for(auto [T,y,i]:v){
        if(y==-1){
            st[t[i]].insert(x[i]);
        }
        if(y==0){
            ll mx=0,mn;
            for(ll j=1;j<=k;j++){
                auto it=st[j].lower_bound(l[i]);
                mn=*it-l[i];
                it--;
                mn=min(mn,l[i]-*it);
                mx=max(mx,mn);
            }
            if(mx>=(ll)1e8){
                mx=-1;
            }
            ans[i]=mx;
        }
        if(y==1){
            st[t[i]].erase(st[t[i]].find(x[i]));
        }
    }
    for(ll i=1;i<=q;i++){
        cout<<ans[i]<<"\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1509 ms 13108 KB Output is correct
32 Correct 91 ms 11724 KB Output is correct
33 Correct 128 ms 14024 KB Output is correct
34 Correct 1204 ms 13588 KB Output is correct
35 Correct 675 ms 14508 KB Output is correct
36 Correct 148 ms 15284 KB Output is correct
37 Correct 120 ms 13048 KB Output is correct
38 Correct 83 ms 12696 KB Output is correct
39 Correct 67 ms 13260 KB Output is correct
40 Correct 66 ms 13052 KB Output is correct
41 Correct 231 ms 12996 KB Output is correct
42 Correct 304 ms 13000 KB Output is correct
43 Correct 213 ms 13560 KB Output is correct
44 Correct 197 ms 13436 KB Output is correct
45 Correct 97 ms 13232 KB Output is correct
46 Correct 63 ms 13488 KB Output is correct
47 Correct 62 ms 12088 KB Output is correct
48 Correct 51 ms 12676 KB Output is correct
49 Correct 64 ms 12736 KB Output is correct
50 Correct 182 ms 12212 KB Output is correct
51 Correct 61 ms 13508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5023 ms 66196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5043 ms 58188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1509 ms 13108 KB Output is correct
32 Correct 91 ms 11724 KB Output is correct
33 Correct 128 ms 14024 KB Output is correct
34 Correct 1204 ms 13588 KB Output is correct
35 Correct 675 ms 14508 KB Output is correct
36 Correct 148 ms 15284 KB Output is correct
37 Correct 120 ms 13048 KB Output is correct
38 Correct 83 ms 12696 KB Output is correct
39 Correct 67 ms 13260 KB Output is correct
40 Correct 66 ms 13052 KB Output is correct
41 Correct 231 ms 12996 KB Output is correct
42 Correct 304 ms 13000 KB Output is correct
43 Correct 213 ms 13560 KB Output is correct
44 Correct 197 ms 13436 KB Output is correct
45 Correct 97 ms 13232 KB Output is correct
46 Correct 63 ms 13488 KB Output is correct
47 Correct 62 ms 12088 KB Output is correct
48 Correct 51 ms 12676 KB Output is correct
49 Correct 64 ms 12736 KB Output is correct
50 Correct 182 ms 12212 KB Output is correct
51 Correct 61 ms 13508 KB Output is correct
52 Execution timed out 5004 ms 22028 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1509 ms 13108 KB Output is correct
32 Correct 91 ms 11724 KB Output is correct
33 Correct 128 ms 14024 KB Output is correct
34 Correct 1204 ms 13588 KB Output is correct
35 Correct 675 ms 14508 KB Output is correct
36 Correct 148 ms 15284 KB Output is correct
37 Correct 120 ms 13048 KB Output is correct
38 Correct 83 ms 12696 KB Output is correct
39 Correct 67 ms 13260 KB Output is correct
40 Correct 66 ms 13052 KB Output is correct
41 Correct 231 ms 12996 KB Output is correct
42 Correct 304 ms 13000 KB Output is correct
43 Correct 213 ms 13560 KB Output is correct
44 Correct 197 ms 13436 KB Output is correct
45 Correct 97 ms 13232 KB Output is correct
46 Correct 63 ms 13488 KB Output is correct
47 Correct 62 ms 12088 KB Output is correct
48 Correct 51 ms 12676 KB Output is correct
49 Correct 64 ms 12736 KB Output is correct
50 Correct 182 ms 12212 KB Output is correct
51 Correct 61 ms 13508 KB Output is correct
52 Execution timed out 5023 ms 66196 KB Time limit exceeded
53 Halted 0 ms 0 KB -