답안 #222891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
222891 2020-04-14T10:10:13 Z ngot23 Deda (COCI17_deda) C++11
20 / 140
135 ms 15352 KB
#include <bits/stdc++.h>

using namespace std;
#define pii pair<long long, long long >
#define F first
#define S second
#define mp make_pair
pair<pii, pii > a[200005];
long long ans[200005];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    //if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
    long long n, Q; cin >> n >> Q;
    for(long long i=1 ; i<=Q ; ++i) {
        char c; cin >> c;
        long long A, B; cin >> A >> B;
        if(c=='M') a[i] = mp( mp(A, 0), mp(B, 0) );
        else a[i] = mp( mp(A, 1), mp(B, i ) );

    }
    set <long long > s;
    sort(a+1, a+Q+1);
    for(long long i=1; i<=Q ; ++i) {
        if(a[i].F.S==0) s.insert(a[i].S.F);
        else {
            auto id = s.lower_bound(a[i].S.F);
            if(id==s.end()) ans[a[i].S.S]=-1;
            else ans[a[i].S.S]=*id;
        }
    }
    for(long long i=1 ; i<=Q ; ++i) {
        if(ans[i]) cout << ans[i] << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Incorrect 7 ms 640 KB Output isn't correct
4 Incorrect 107 ms 12664 KB Output isn't correct
5 Incorrect 135 ms 15352 KB Output isn't correct
6 Incorrect 130 ms 14840 KB Output isn't correct
7 Incorrect 127 ms 14556 KB Output isn't correct