Submission #933477

# Submission time Handle Problem Language Result Execution time Memory
933477 2024-02-25T17:49:26 Z sleepntsheep Martian DNA (BOI18_dna) C++17
100 / 100
184 ms 9268 KB
#include<stdio.h>
unsigned X=12345;int rand_(){return(X*=3)>>1;}
#define N 200002
int n,k,rn,a[N],ii[N],ff[N];
#include<set>
#include<utility>
std::set<std::pair<int,int>>ss;

int t;
void add(int i,int k)
{
    if(!ii[i])return;
    ss.erase({ff[i],i});
    ss.insert({ff[i]+=k,i});
}

int main()
{
    scanf("%d%d%d",&n,&k,&rn);
    for(int i=0;i<n;++i)scanf("%d",a+i);
    for(int b,q;rn--;)
        scanf("%d%d",&b,&q),ss.insert({-q,b}),ii[b]=1,ff[b]=-q;
    int l=0,r=0,z=1e9;
    while(l<n)
    {
        while(r<=l)add(a[r++],1);
        while(ss.begin()->first<0&&r<n)add(a[r++],1);
        if(ss.begin()->first>=0&&z>r-l)z=r-l;
        add(a[l++],-1);
    }
    if(z==1e9)puts("impossible");else printf("%d",z);
}


Compilation message

dna.cpp: In function 'int main()':
dna.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d%d%d",&n,&k,&rn);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
dna.cpp:20:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     for(int i=0;i<n;++i)scanf("%d",a+i);
      |                         ~~~~~^~~~~~~~~~
dna.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d%d",&b,&q),ss.insert({-q,b}),ii[b]=1,ff[b]=-q;
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 600 KB Output is correct
12 Correct 0 ms 432 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1112 KB Output is correct
2 Correct 23 ms 1368 KB Output is correct
3 Correct 32 ms 1628 KB Output is correct
4 Correct 42 ms 1584 KB Output is correct
5 Correct 16 ms 2388 KB Output is correct
6 Correct 43 ms 1372 KB Output is correct
7 Correct 19 ms 1640 KB Output is correct
8 Correct 17 ms 2400 KB Output is correct
9 Correct 15 ms 2136 KB Output is correct
10 Correct 44 ms 1372 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 436 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 177 ms 5468 KB Output is correct
2 Correct 140 ms 6156 KB Output is correct
3 Correct 51 ms 3676 KB Output is correct
4 Correct 23 ms 1368 KB Output is correct
5 Correct 184 ms 7736 KB Output is correct
6 Correct 171 ms 9268 KB Output is correct
7 Correct 117 ms 2396 KB Output is correct
8 Correct 135 ms 3260 KB Output is correct
9 Correct 33 ms 1372 KB Output is correct
10 Correct 23 ms 1372 KB Output is correct
11 Correct 33 ms 1624 KB Output is correct
12 Correct 33 ms 1368 KB Output is correct
13 Correct 15 ms 2396 KB Output is correct
14 Correct 46 ms 1372 KB Output is correct
15 Correct 17 ms 1628 KB Output is correct
16 Correct 17 ms 2456 KB Output is correct
17 Correct 15 ms 2132 KB Output is correct
18 Correct 44 ms 1368 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 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 360 KB Output is correct