제출 #1150203

#제출 시각아이디문제언어결과실행 시간메모리
1150203tnt Martian DNA (BOI18_dna)C++20
0 / 100
145 ms128832 KiB
#include <bits/stdc++.h> using namespace std; //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") #define pb push_back #define ll long long #define int long long //#define sort(all(v)) sort(v.begin(),v.end()) int mod = 1e9 + 7; const int N = 4000 + 100; const int inf = 2e9; int pr[N][N]; signed main(){ //freopen("shuffle.in", "r", stdin); //freopen("shuffle.out", "w", stdout); int n,k,q; cin >> n >> k >> q; int a[n + 1]; for(int i = 1; i <= n; i++){ cin >> a[i]; if(n <= 4000){ for(int j = 0; j < k; j++){ pr[i][j] = pr[i - 1][j] + (a[i] == j); } } } vector <pair<int,int>> v; while(q--){ int b,d; cin >> b >> d; v.pb({b,d}); } if(n > 4000){ cout << "impossible"; return 0; } int ans = 1e9; for(int i = 1; i <= n; i++){ for(int j = i + 1; j <= n; j++){ bool f = 0; for(auto to : v){ if(pr[j][to.first] - pr[i - 1][to.first] < to.second){ f = 1; break; } } if(f == 0){ ans = min(ans, j - i + 1); } } } if(ans == 1e9) cout << "impossible"; else cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...