# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
472860 | AbdoMo | Deda (COCI17_deda) | C++17 | 1099 ms | 1544 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define pb push_back
const int mod = 1e9+7;
using namespace std;
bool comp(pair<int,pair<int,int>>a,pair<int,pair<int,int>>b)
{
int qa=a.first;
int qb=b.first;
int dua=a.second.first;
int dub=b.second.first;
int inda=a.second.second;
int indb=b.second.second;
if(qa == qb)
{
if(dua == dub)
{
return (inda<indb);
}
return (dua>dub);
}
return (qa>qb);
}
void solve(){
int n,q;
cin>>n>>q;
set<pair<int,int>>v;
while(q--)
{
char x;
cin>>x;
if(x == 'M')
{
int age,stat;
cin>>stat>>age;
//with age b got off at station a
v.insert({stat,age});
}
else
{
int age,stat;
cin>>stat>>age;
int ans=1e12;
auto st=v.begin();
auto en=v.upper_bound({stat,-1});
for(auto i=st;i!=en;i++)
{
if(i->second>=age)
{
ans=min(ans,i->second);
}
}
if(ans==1e12)
cout<<-1<<endl;
else
cout<<ans<<endl;
}
}
}
int32_t main(){
int t=1;
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//cin>>t;
while(t--){solve();}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |