답안 #947484

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947484 2024-03-16T09:28:17 Z vjudge306 Martian DNA (BOI18_dna) C++14
0 / 100
236 ms 16560 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nn "\n"
#define x_x ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define intt int _; cin >> _; while (_--)
#define emp push_back
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define ld long double
#define A first
#define B second
typedef long long ll;
const ld eps = 1e-27;
// diff between decimals 0.000000001 mt19937 mt(time(nullptr));

int main() {

    x_x
int n, k, r; cin>>n>>k>>r; map<int,int>mp,f;
int ar[n];
for(int i=0; i<n; i++)
cin>>ar[i];
int z=0;
for(int i=0, a,b; i<r;i++)
cin>>a>>b, mp[a]=b, z+=(b==0);

int sz=5+n;
for(int i=0, j=0; j<n&&i<n;) {
while (z<r&&j<n) {
f[ar[j]]++; 
if (mp.find(ar[j])!=mp.end()&&f[ar[j]]==mp[ar[j]])z++;
j++;
}
if(z==r)sz=min(sz,j-i);
if(mp.find(ar[i])!=mp.end()&&f[ar[i]]==mp[ar[i]])
z-=1; 
f[ar[i]]-=1;  i++;
}
if(sz>n) cout<<"impossible"; else cout<<sz;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 488 KB Output is correct
6 Correct 1 ms 344 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 452 KB Output is correct
12 Incorrect 0 ms 600 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1368 KB Output is correct
2 Correct 11 ms 1372 KB Output is correct
3 Correct 17 ms 1664 KB Output is correct
4 Correct 16 ms 1624 KB Output is correct
5 Correct 64 ms 6232 KB Output is correct
6 Correct 14 ms 1624 KB Output is correct
7 Correct 18 ms 1624 KB Output is correct
8 Correct 104 ms 11684 KB Output is correct
9 Correct 46 ms 2396 KB Output is correct
10 Correct 19 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 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Incorrect 0 ms 348 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 191 ms 10324 KB Output is correct
2 Correct 179 ms 8444 KB Output is correct
3 Correct 116 ms 6188 KB Output is correct
4 Correct 10 ms 1628 KB Output is correct
5 Correct 149 ms 11616 KB Output is correct
6 Correct 236 ms 16560 KB Output is correct
7 Correct 80 ms 2964 KB Output is correct
8 Correct 120 ms 3924 KB Output is correct
9 Correct 14 ms 1880 KB Output is correct
10 Correct 11 ms 1372 KB Output is correct
11 Correct 17 ms 1628 KB Output is correct
12 Correct 16 ms 1624 KB Output is correct
13 Correct 70 ms 6124 KB Output is correct
14 Correct 14 ms 1624 KB Output is correct
15 Correct 17 ms 1628 KB Output is correct
16 Correct 93 ms 11832 KB Output is correct
17 Correct 42 ms 2648 KB Output is correct
18 Correct 19 ms 1488 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 480 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 456 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Incorrect 0 ms 600 KB Output isn't correct
31 Halted 0 ms 0 KB -