답안 #136948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
136948 2019-07-26T16:05:14 Z dnass Poklon (COCI17_poklon) C++14
56 / 140
374 ms 632 KB
#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

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);
             ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 20 ms 376 KB Output is correct
4 Correct 374 ms 632 KB Output is correct
5 Incorrect 3 ms 376 KB Output isn't correct
6 Incorrect 3 ms 376 KB Output isn't correct
7 Incorrect 5 ms 632 KB Output isn't correct
8 Incorrect 12 ms 504 KB Output isn't correct
9 Incorrect 6 ms 504 KB Output isn't correct
10 Incorrect 4 ms 376 KB Output isn't correct