Submission #1018819

#TimeUsernameProblemLanguageResultExecution timeMemory
1018819biserailievaPoklon (COCI17_poklon)C++14
56 / 140
5088 ms4284 KiB
#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 timeMemoryGrader output
Fetching results...