답안 #1033068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1033068 2024-07-24T12:33:06 Z vannnnnnnn Martian DNA (BOI18_dna) C++14
100 / 100
27 ms 5212 KB
#include<bits/stdc++.h>
using namespace std;
int note[200005], lst[200005], mp[200005], a[200005];
int main()
{
	int n, k, r, ans=1e9;
	scanf("%d %d %d", &n, &k, &r);
	for(int i=1; i<=n; i++)
	{
		scanf("%d", &a[i]);
	}
	for(int i=1; i<=r; i++)
	{
		int c, d;
		scanf("%d %d", &c, &d);
		note[c]=d;
		lst[i]=c;
	}
	int start=1, find=0;
	for(int i=1; i<=n; i++)
	{
		mp[a[i]]++;
		if(find==0)
		{
			find=1;
			for(int j=1; j<=r; j++)
			{
				if(mp[lst[j]]<note[lst[j]])
				{
					find=0;
					break;
				}
			}	
		}
		while(start<i)
		{
			if(mp[a[start]]-1>=note[a[start]])
			{
				mp[a[start]]--;
				start++;
			}
			else
			{
				break;
			}
		}
		if(find==1)
		{
			ans=min(ans, i-start+1);
		}
	}
	if(ans==1e9)printf("impossible\n");
	else printf("%d\n", ans);
}

Compilation message

dna.cpp: In function 'int main()':
dna.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%d %d %d", &n, &k, &r);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dna.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~
dna.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d %d", &c, &d);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 0 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 2672 KB Output is correct
2 Correct 11 ms 2652 KB Output is correct
3 Correct 11 ms 2652 KB Output is correct
4 Correct 10 ms 2652 KB Output is correct
5 Correct 12 ms 2672 KB Output is correct
6 Correct 9 ms 2652 KB Output is correct
7 Correct 10 ms 2652 KB Output is correct
8 Correct 14 ms 2652 KB Output is correct
9 Correct 12 ms 2652 KB Output is correct
10 Correct 10 ms 2652 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 2908 KB Output is correct
2 Correct 20 ms 4444 KB Output is correct
3 Correct 18 ms 4188 KB Output is correct
4 Correct 12 ms 2908 KB Output is correct
5 Correct 24 ms 5200 KB Output is correct
6 Correct 27 ms 5212 KB Output is correct
7 Correct 13 ms 3676 KB Output is correct
8 Correct 25 ms 3932 KB Output is correct
9 Correct 10 ms 2908 KB Output is correct
10 Correct 12 ms 3016 KB Output is correct
11 Correct 11 ms 2904 KB Output is correct
12 Correct 10 ms 3044 KB Output is correct
13 Correct 15 ms 2536 KB Output is correct
14 Correct 22 ms 1596 KB Output is correct
15 Correct 10 ms 1624 KB Output is correct
16 Correct 15 ms 3160 KB Output is correct
17 Correct 16 ms 2140 KB Output is correct
18 Correct 11 ms 1620 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct