답안 #472856

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472856 2021-09-14T12:09:11 Z AbdoMo Deda (COCI17_deda) C++17
80 / 140
1000 ms 1516 KB
#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;
    vector<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.pb({stat,age});
        }
        else
        {
            int age,stat;
            cin>>stat>>age;
            int ans=1e12;
            for(int i=0;i<v.size();i++)
            {
                if(v[i].second>=age && v[i].first<=stat)
                {

                    ans=min(ans,v[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;
}

Compilation message

deda.cpp: In function 'void solve()':
deda.cpp:47:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             for(int i=0;i<v.size();i++)
      |                         ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 16 ms 356 KB Output is correct
4 Correct 565 ms 1516 KB Output is correct
5 Execution timed out 1092 ms 832 KB Time limit exceeded
6 Execution timed out 1083 ms 768 KB Time limit exceeded
7 Execution timed out 1060 ms 872 KB Time limit exceeded