Submission #933251

#TimeUsernameProblemLanguageResultExecution timeMemory
933251LucaIlie Martian DNA (BOI18_dna)C++17
0 / 100
2065 ms2648 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5; const int MAX_K = MAX_N; int v[MAX_N], f[MAX_K], q[MAX_K]; int cond; void add( int i ) { f[v[i]]++; if ( f[v[i]] == q[v[i]] ) cond++; } void rem( int i ) { if ( f[v[i]] == q[v[i]] ) cond--; f[v[i]]--; } int main() { int n, k, m; cin >> n >> k >> m; for ( int i = 0; i < n; i++ ) cin >> v[i]; for ( int i = 0; i < m; i++ ) { int b; cin >> b; cin >> q[b]; } /*cond = k - m; int l = 0, minLen = n + 1; for ( int r = 0; r < n; r++ ) { add( r ); while ( cond >= k && l <= r ) { rem( l ); l++; } if ( l > 0 ) { l--; add( l ); } if ( cond >= k ) minLen = min( minLen, r - l + 1 ); }*/ cond = k - m; int minLen = n + 1; for ( int l = 0; l < n; l++ ) { for ( int r = l; r < n; r++ ) { add( r ); if ( cond == k ) minLen = min( minLen, r - l + 1 ); } for ( int r = l; r < n; r++ ) rem( r ); } if ( minLen == n + 1 ) cout << "Immposible\n"; else cout << minLen << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...