# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
879543 | Victor_9 | Deda (COCI17_deda) | C++14 | 1051 ms | 1360 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//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<<'\n';
ok=1;
break;
}
}
if(ok==0){
cout<<-1<<'\n';
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |