답안 #879542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879542 2023-11-27T15:58:23 Z Victor_9 Deda (COCI17_deda) C++14
80 / 140
1000 ms 1260 KB
//x
#include <bits/stdc++.h>
using namespace std;
const int NMax=2e5+5;
 
int n, q, s, c, l, poz, ok, cnt;
char nume;
vector<pair<int, int>>v;
 
 
struct compare { 
 bool operator()(const pair<int, int>& value, 
        const int& key) 
 { 
  return (value.first < key); 
 } 
 bool operator()(const int& key, 
     const pair<int, int>& value) 
 { 
  return (key < value.first); 
 } 
};
 
int main()
{
    cin>>n>>q;
 
    for(int i=1;i<=q;i++){
        cin>>nume>>s>>c;
        ok=0;
        if(nume=='M'){
            v.push_back({c,s});
            l++;
            cnt=1;
        }
        if(nume=='D'){
            if(cnt==1){
                sort(v.begin() , v.end());
                cnt=0;
            }
            poz=lower_bound(v.begin(), v.end(), c, compare())-v.begin();
            for(int j=poz;j<l;j++){
                if(v[j].second<=s){
                    cout<<v[j].first<<endl;
                    ok=1;
                    break;
                }
            }
            if(ok==0){
                cout<<-1<<'\n';
            }
        }
    }
    
    
    
    
}
 
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 17 ms 452 KB Output is correct
4 Correct 355 ms 1260 KB Output is correct
5 Execution timed out 1094 ms 856 KB Time limit exceeded
6 Execution timed out 1063 ms 852 KB Time limit exceeded
7 Execution timed out 1027 ms 836 KB Time limit exceeded