Submission #136948

#TimeUsernameProblemLanguageResultExecution timeMemory
136948dnassPoklon (COCI17_poklon)C++14
56 / 140
374 ms632 KiB
#include <bits/stdc++.h> using namespace std; int n, q; int a[5010]; int main(){ scanf("%d %d", &n, &q); for(int i=0;i<n;i++) scanf("%d", &a[i]); while(q--){ int l, r; scanf("%d %d", &l, &r); --l; --r; vector<int> x; for(int i=l;i<=r;i++) x.push_back(a[i]); sort(x.begin(), x.end()); int beg = 0, ans = 0; for(int i=1;i<=(int) x.size();i++){ if(i==(int) x.size()||x[i]!=x[i-1]){ if(i-beg==2) ans++; beg = i; } } printf("%d\n", ans); } return 0; }

Compilation message (stderr)

poklon.cpp: In function 'int main()':
poklon.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~~
poklon.cpp:9:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++) scanf("%d", &a[i]);
                       ~~~~~^~~~~~~~~~~~~
poklon.cpp:11:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int l, r; scanf("%d %d", &l, &r);
             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...