Submission #1018819

# Submission time Handle Problem Language Result Execution time Memory
1018819 2024-07-10T10:02:37 Z biserailieva Poklon (COCI17_poklon) C++14
56 / 140
5000 ms 4284 KB
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n, q;
    cin>>n>>q;
    int A[n];
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }
    for(int i=0;i<q;i++)
    {
        int l, r;
        cin>>l>>r;
        map<int, int>freq;
        int cnt=0;
        for(int i=l-1;i<=r-1;i++)
        {
            freq[A[i]]++;
        }
        for(int i=l-1;i<=r-1;i++)
        {
            if(freq[A[i]]==2)
            {
                cnt++;
                freq[A[i]]=0;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Correct 29 ms 444 KB Output is correct
4 Correct 460 ms 500 KB Output is correct
5 Execution timed out 5053 ms 1308 KB Time limit exceeded
6 Execution timed out 5032 ms 1308 KB Time limit exceeded
7 Execution timed out 5088 ms 2096 KB Time limit exceeded
8 Execution timed out 5035 ms 3152 KB Time limit exceeded
9 Execution timed out 5034 ms 3412 KB Time limit exceeded
10 Execution timed out 5036 ms 4284 KB Time limit exceeded