Submission #973036

# Submission time Handle Problem Language Result Execution time Memory
973036 2024-05-01T12:43:42 Z vjudge1 Deda (COCI17_deda) C++17
80 / 140
1000 ms 52628 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n,q;
    long long a[n+5];
    cin>>n>>q;
    for(int i=0;i<=n;i++){
        a[i]=0;
    }
    vector<long long> v;
    string s;
    long long x,b;
    while(q--){
        cin>>s>>x>>b;
        if(s=="M"){
            a[b]=x;
            v.push_back(b);
        }
        else{
            sort(v.begin(),v.end());
            int flag=1;
            for(int i=0;i<v.size();i++){
                if(v[i]>=b){
                    if(a[v[i]]<=x){
                        cout<<v[i]<<'\n';
                        flag=0;
                        break;
                    }
                }
            }
            if(flag){
                cout<<"-1\n";
            }
        }
    }
    return 0;
}

Compilation message

deda.cpp: In function 'int main()':
deda.cpp:25:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             for(int i=0;i<v.size();i++){
      |                         ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 22 ms 48220 KB Output is correct
2 Correct 23 ms 48220 KB Output is correct
3 Correct 44 ms 48208 KB Output is correct
4 Correct 334 ms 52628 KB Output is correct
5 Execution timed out 1059 ms 48996 KB Time limit exceeded
6 Execution timed out 1068 ms 49124 KB Time limit exceeded
7 Execution timed out 1049 ms 49156 KB Time limit exceeded