답안 #879545

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879545 2023-11-27T16:02:09 Z Victor_9 Deda (COCI17_deda) C++17
80 / 140
1000 ms 1364 KB
//x
#include <bits/stdc++.h>
using namespace std;
const int NMax=2e5+5;
//ifstream fin("x.in");
 
int n, q, i, j, s, c, l, poz, ok;
char nume;
vector<pair<int, int>>v;
 
// bool compare(int a, int b){
//     if(a.first>b.first){
//         return 1;
//     }
//     return 0;
// }
 
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(i=1;i<=q;i++){
        cin>>nume>>s>>c;
        ok=0;
        if(nume=='M'){
            v.push_back({c,s});
            sort(v.begin() , v.end());
            l++;
        }
        if(nume=='D'){
           poz=lower_bound(v.begin(), v.end(), c, compare())-v.begin();
           //cout<<poz<<" ";
            for(j=poz;j<l;j++){
                if(v[j].second<=s){
                    cout<<v[j].first<<'\n';
                    ok=1;
                    break;
                }
            }
            if(ok==0){
                cout<<-1<<'\n';
            }
        }
    }
    
    // for(i=0;i<l;i++){
    //     cout<<v[i].first<<" ";
    // }
    
    
    
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 18 ms 460 KB Output is correct
4 Correct 381 ms 1364 KB Output is correct
5 Execution timed out 1028 ms 656 KB Time limit exceeded
6 Execution timed out 1050 ms 972 KB Time limit exceeded
7 Execution timed out 1061 ms 828 KB Time limit exceeded