Submission #526039

# Submission time Handle Problem Language Result Execution time Memory
526039 2022-02-13T15:26:49 Z Snowfall Martian DNA (BOI18_dna) C++14
100 / 100
36 ms 4440 KB
#include<bits/stdc++.h>
using namespace std;
int uck;
int arr[200005];
int cn[200005],cur[200005];
main()
{
	int t,q,a;
    scanf("%d%d%d",&t,&a,&q);
    uck=q;
    for(int i = 1;i <= t;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(int i = 1;i <= q;i++)
    {
        int m,n;
        scanf("%d%d",&m,&n);
        cn[m]=n;
    }
    int st=1,mn=1e9;
    for(int i = 1;i <= t;i++)
    {
        cur[arr[i]]++;
        if(cur[arr[i]]==cn[arr[i]])
        {
            uck--;
        }
        while(uck==0)
        {
            mn=min(mn,i-st+1);
            if(cur[arr[st]]==cn[arr[st]])
            {
                uck++;
            }
            cur[arr[st]]--;
            st++;
        }
    }
    if(mn==1e9)
    printf("impossible");
    else
    printf("%d",mn);
}

Compilation message

dna.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~
dna.cpp: In function 'int main()':
dna.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d%d%d",&t,&a,&q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
dna.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d",&arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~
dna.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d%d",&m,&n);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 2 ms 288 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1396 KB Output is correct
2 Correct 18 ms 1404 KB Output is correct
3 Correct 18 ms 1508 KB Output is correct
4 Correct 17 ms 1496 KB Output is correct
5 Correct 23 ms 2480 KB Output is correct
6 Correct 14 ms 1456 KB Output is correct
7 Correct 15 ms 1588 KB Output is correct
8 Correct 30 ms 3036 KB Output is correct
9 Correct 22 ms 2064 KB Output is correct
10 Correct 18 ms 1448 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 300 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 296 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 3448 KB Output is correct
2 Correct 29 ms 3060 KB Output is correct
3 Correct 26 ms 2820 KB Output is correct
4 Correct 15 ms 1436 KB Output is correct
5 Correct 30 ms 4020 KB Output is correct
6 Correct 36 ms 4440 KB Output is correct
7 Correct 17 ms 2124 KB Output is correct
8 Correct 20 ms 2360 KB Output is correct
9 Correct 14 ms 1384 KB Output is correct
10 Correct 21 ms 1432 KB Output is correct
11 Correct 16 ms 1508 KB Output is correct
12 Correct 15 ms 1460 KB Output is correct
13 Correct 18 ms 2488 KB Output is correct
14 Correct 14 ms 1456 KB Output is correct
15 Correct 16 ms 1612 KB Output is correct
16 Correct 23 ms 3140 KB Output is correct
17 Correct 17 ms 1988 KB Output is correct
18 Correct 15 ms 1348 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 308 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 316 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 296 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 0 ms 296 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct