답안 #606781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
606781 2022-07-26T08:20:54 Z ntmp Martian DNA (BOI18_dna) C++14
100 / 100
291 ms 11812 KB
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,r;
    cin>>n>>k>>r;
    int a[n+1];
    map<int,int> mp;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<r;i++)
    {
        int x,y;
        cin>>x>>y;
        mp[x]=y;
    }
    int bad=r;
    int res=n+1,vt=0,j=0;
    for(int i=0;i<n;i++)
    {
        /*for(int j=vt;j<n;j++)
        if(bad>0)
        {
            //cout<<i<<' '<<j<<endl;
            mp[a[j]]--;
            if(mp[a[j]]==0) bad--;
        }
        else
        {
            cout<<j<<' '<<i<<endl;
            vt=j;
            res=min(res,j-i);
            break;
        }*/
        while(j<n && bad>0)
        {
            mp[a[j]]--;
            if(mp[a[j]]==0) bad--;
            j++;
        }
        if(bad==0) res=min(res,j-i);
        mp[a[i]]++;
        if(mp[a[i]]==1) bad++;
    }
    if(res==n+1) cout<<"impossible"<<endl;
    else cout<<res<<endl;
}

Compilation message

dna.cpp: In function 'int main()':
dna.cpp:18:17: warning: unused variable 'vt' [-Wunused-variable]
   18 |     int res=n+1,vt=0,j=0;
      |                 ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 3 ms 436 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 1444 KB Output is correct
2 Correct 31 ms 1440 KB Output is correct
3 Correct 34 ms 1448 KB Output is correct
4 Correct 33 ms 1444 KB Output is correct
5 Correct 155 ms 5956 KB Output is correct
6 Correct 37 ms 1364 KB Output is correct
7 Correct 56 ms 1592 KB Output is correct
8 Correct 225 ms 11812 KB Output is correct
9 Correct 114 ms 2388 KB Output is correct
10 Correct 35 ms 1440 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 3 ms 312 KB Output is correct
16 Correct 2 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 296 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 236 ms 6696 KB Output is correct
2 Correct 183 ms 5476 KB Output is correct
3 Correct 152 ms 5172 KB Output is correct
4 Correct 30 ms 1364 KB Output is correct
5 Correct 289 ms 7920 KB Output is correct
6 Correct 291 ms 11592 KB Output is correct
7 Correct 116 ms 2384 KB Output is correct
8 Correct 149 ms 3248 KB Output is correct
9 Correct 30 ms 1460 KB Output is correct
10 Correct 31 ms 1364 KB Output is correct
11 Correct 34 ms 1492 KB Output is correct
12 Correct 31 ms 1356 KB Output is correct
13 Correct 153 ms 5964 KB Output is correct
14 Correct 45 ms 1364 KB Output is correct
15 Correct 54 ms 1628 KB Output is correct
16 Correct 254 ms 11720 KB Output is correct
17 Correct 124 ms 2328 KB Output is correct
18 Correct 43 ms 1444 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 2 ms 304 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 4 ms 468 KB Output is correct
23 Correct 3 ms 312 KB Output is correct
24 Correct 2 ms 304 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 300 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 300 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct