# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
668579 | 2022-12-04T07:08:44 Z | ktkerem | Martian DNA (BOI18_dna) | C++11 | 52 ms | 6916 KB |
/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/ #include<bits/stdc++.h> /**/ //typedef int ll; typedef long long ll; typedef unsigned long long ull; typedef std::string str; //typedef vector<std::vector<ll>> vv; /*typedef __int128 vll; typedef unsigned __int128 uvll;*/ #define llll std::pair<ll , ll> #define pb push_back #define pf push_front #define halo cout << "hello\n" #define fi first #define sec second #define vv(x) std::vector<std::vector<x>> #define all(a) a.begin() , a.end() const ll limit = 1e15+7; const ll ous = 3e5 + 7; const ll dx[4] = {-1 , 0 , 1 , 0} , dy[4] = {0,1,0,-1}; ll n , m , k;std::vector<ll> ar; std::vector<ll> kt; ll tot = 0; ll fd(ll sz){ std::vector<ll> vt(m+5 , 0); ll p = 0; for(ll i = 0;sz>i;i++){ if(kt[ar[i]] > vt[ar[i]]){ p++; } vt[ar[i]]++; } if(p == tot){ return 1; } for(ll i = sz;n>i;i++){ if(kt[ar[i]] > vt[ar[i]]){ p++; } vt[ar[i]]++; if(kt[ar[i-sz]] >= vt[ar[i-sz]]){ p--; } vt[ar[i - sz]]--; if(p == tot){ return 1; } } if(p == tot){ return 1; } return 0; } void solve(){ std::cin >> n >> m >> k; kt.resize(m+5 , 0); ar.resize(n); for(ll i = 0;n>i;i++){ std::cin >> ar[i]; } for(ll i = 0;k>i;i++){ ll x , y;std::cin >> x >> y; kt[x]+=y; tot+=y; } ll l = 1 , r = n+1; while(r > l){ ll md = (r + l)/2; if(fd(md)){ r = md; } else{ l = md + 1; } } if(l == n+1){ std::cout << "impossible\n"; return; } std::cout << l << "\n"; return;/**/ } signed main(){ std::ios_base::sync_with_stdio(false);std::cin.tie(NULL); ll t=1; //std::cin >> t; ll o = 1; while(t--){ //cout << "Case " << o++ << ":\n"; solve(); } return 0; }/**/
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 320 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 320 KB | Output is correct |
5 | Correct | 0 ms | 316 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 324 KB | Output is correct |
8 | Correct | 0 ms | 312 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 324 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 388 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 320 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 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 | 22 ms | 2260 KB | Output is correct |
2 | Correct | 24 ms | 2260 KB | Output is correct |
3 | Correct | 16 ms | 2260 KB | Output is correct |
4 | Correct | 24 ms | 2264 KB | Output is correct |
5 | Correct | 31 ms | 4184 KB | Output is correct |
6 | Correct | 21 ms | 2264 KB | Output is correct |
7 | Correct | 21 ms | 2388 KB | Output is correct |
8 | Correct | 39 ms | 6256 KB | Output is correct |
9 | Correct | 26 ms | 2976 KB | Output is correct |
10 | Correct | 26 ms | 2260 KB | Output is correct |
11 | Correct | 1 ms | 356 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 4824 KB | Output is correct |
2 | Correct | 38 ms | 4416 KB | Output is correct |
3 | Correct | 32 ms | 4052 KB | Output is correct |
4 | Correct | 10 ms | 2252 KB | Output is correct |
5 | Correct | 42 ms | 5588 KB | Output is correct |
6 | Correct | 52 ms | 6916 KB | Output is correct |
7 | Correct | 28 ms | 2968 KB | Output is correct |
8 | Correct | 33 ms | 3364 KB | Output is correct |
9 | Correct | 24 ms | 2268 KB | Output is correct |
10 | Correct | 25 ms | 2260 KB | Output is correct |
11 | Correct | 16 ms | 2264 KB | Output is correct |
12 | Correct | 22 ms | 2256 KB | Output is correct |
13 | Correct | 30 ms | 4176 KB | Output is correct |
14 | Correct | 21 ms | 2248 KB | Output is correct |
15 | Correct | 21 ms | 2380 KB | Output is correct |
16 | Correct | 40 ms | 6272 KB | Output is correct |
17 | Correct | 28 ms | 2900 KB | Output is correct |
18 | Correct | 26 ms | 2252 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 336 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 316 KB | Output is correct |
26 | Correct | 0 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 316 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 212 KB | Output is correct |