# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
927061 |
2024-02-14T07:57:10 Z |
vjudge1 |
Martian DNA (BOI18_dna) |
C++17 |
|
66 ms |
35404 KB |
// By ObeliX
#include <bits/stdc++.h>
#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include <unordered_map>
#include <cstddef>
#include <cassert>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
const long long N = 1e6 + 5;
const long long mod = 1e9+7;
const long long INF = 1e18;
string al = "abcdefghijklmnopqrstuvwxyz";
long long n , k , r;
long long x[N];
long long a[N];
vector <int> v[N];
int main(){
//freopen( "cinema.in" , "r" , stdin );
//freopen( "cinema.out" , "w" , stdout );
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k >> r;
for ( int i = 1 ; i <= n ; i++ ) {
cin >> a[i];
v[a[i]].push_back( i );
}
long long ans = 0;
int can = 0;
for ( int i = 1 ; i <= r ; i++ ) {
long long x1 , y;
cin >> x1 >> y;
if ( v[x1].size() < y ) {
can = 1;
}
else {
ans = max( ans , 1ll * v[x1][y-1] );
}
x[x1] = y;
}
if ( can == 1 ) {
cout << "impossible";
return 0;
}
long long mx = ans;
for ( int i = 1 ; i <= n ; i++ ) {
ans = min( ans , mx - i + 1 );
if ( x[a[i]] != 0 ) {
x[a[i]]++;
if ( x[a[i]] > v[a[i]].size() ) {
break;
}
mx = max( mx , 1ll * v[a[i]][x[a[i]] - 1] );
}
}
cout << ans;
}
Compilation message
dna.cpp: In function 'int main()':
dna.cpp:46:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
46 | if ( v[x1].size() < y ) {
| ~~~~~~~~~~~~~^~~
dna.cpp:63:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | if ( x[a[i]] > v[a[i]].size() ) {
| ~~~~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
27228 KB |
Output is correct |
2 |
Correct |
6 ms |
27228 KB |
Output is correct |
3 |
Correct |
6 ms |
27320 KB |
Output is correct |
4 |
Correct |
5 ms |
27228 KB |
Output is correct |
5 |
Correct |
6 ms |
27228 KB |
Output is correct |
6 |
Correct |
6 ms |
27228 KB |
Output is correct |
7 |
Correct |
6 ms |
27228 KB |
Output is correct |
8 |
Correct |
5 ms |
27224 KB |
Output is correct |
9 |
Correct |
5 ms |
27228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
27228 KB |
Output is correct |
2 |
Correct |
6 ms |
27228 KB |
Output is correct |
3 |
Correct |
6 ms |
27384 KB |
Output is correct |
4 |
Correct |
6 ms |
27228 KB |
Output is correct |
5 |
Correct |
6 ms |
27228 KB |
Output is correct |
6 |
Correct |
6 ms |
27228 KB |
Output is correct |
7 |
Correct |
5 ms |
27228 KB |
Output is correct |
8 |
Correct |
6 ms |
27228 KB |
Output is correct |
9 |
Correct |
6 ms |
27228 KB |
Output is correct |
10 |
Correct |
6 ms |
27236 KB |
Output is correct |
11 |
Correct |
6 ms |
27228 KB |
Output is correct |
12 |
Correct |
5 ms |
27228 KB |
Output is correct |
13 |
Correct |
6 ms |
27324 KB |
Output is correct |
14 |
Correct |
6 ms |
27228 KB |
Output is correct |
15 |
Correct |
5 ms |
27228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
30556 KB |
Output is correct |
2 |
Correct |
16 ms |
30320 KB |
Output is correct |
3 |
Correct |
15 ms |
30168 KB |
Output is correct |
4 |
Correct |
15 ms |
30512 KB |
Output is correct |
5 |
Correct |
27 ms |
31836 KB |
Output is correct |
6 |
Correct |
14 ms |
30556 KB |
Output is correct |
7 |
Correct |
15 ms |
30300 KB |
Output is correct |
8 |
Correct |
56 ms |
35404 KB |
Output is correct |
9 |
Correct |
26 ms |
30488 KB |
Output is correct |
10 |
Correct |
15 ms |
30460 KB |
Output is correct |
11 |
Correct |
6 ms |
27480 KB |
Output is correct |
12 |
Correct |
7 ms |
27228 KB |
Output is correct |
13 |
Correct |
6 ms |
27224 KB |
Output is correct |
14 |
Correct |
8 ms |
27228 KB |
Output is correct |
15 |
Correct |
6 ms |
27228 KB |
Output is correct |
16 |
Correct |
6 ms |
27228 KB |
Output is correct |
17 |
Correct |
6 ms |
27256 KB |
Output is correct |
18 |
Correct |
5 ms |
27228 KB |
Output is correct |
19 |
Correct |
5 ms |
27228 KB |
Output is correct |
20 |
Correct |
6 ms |
27272 KB |
Output is correct |
21 |
Correct |
6 ms |
27228 KB |
Output is correct |
22 |
Correct |
5 ms |
27228 KB |
Output is correct |
23 |
Correct |
5 ms |
27228 KB |
Output is correct |
24 |
Correct |
6 ms |
27228 KB |
Output is correct |
25 |
Correct |
5 ms |
27256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
31836 KB |
Output is correct |
2 |
Correct |
41 ms |
31392 KB |
Output is correct |
3 |
Correct |
31 ms |
31160 KB |
Output is correct |
4 |
Correct |
15 ms |
30196 KB |
Output is correct |
5 |
Correct |
42 ms |
32528 KB |
Output is correct |
6 |
Correct |
66 ms |
35164 KB |
Output is correct |
7 |
Correct |
24 ms |
30680 KB |
Output is correct |
8 |
Correct |
28 ms |
30804 KB |
Output is correct |
9 |
Correct |
14 ms |
30552 KB |
Output is correct |
10 |
Correct |
18 ms |
30480 KB |
Output is correct |
11 |
Correct |
15 ms |
30168 KB |
Output is correct |
12 |
Correct |
15 ms |
30592 KB |
Output is correct |
13 |
Correct |
27 ms |
31836 KB |
Output is correct |
14 |
Correct |
15 ms |
30808 KB |
Output is correct |
15 |
Correct |
19 ms |
30344 KB |
Output is correct |
16 |
Correct |
36 ms |
35388 KB |
Output is correct |
17 |
Correct |
22 ms |
30556 KB |
Output is correct |
18 |
Correct |
15 ms |
30456 KB |
Output is correct |
19 |
Correct |
6 ms |
27224 KB |
Output is correct |
20 |
Correct |
6 ms |
27228 KB |
Output is correct |
21 |
Correct |
7 ms |
27228 KB |
Output is correct |
22 |
Correct |
6 ms |
27272 KB |
Output is correct |
23 |
Correct |
6 ms |
27228 KB |
Output is correct |
24 |
Correct |
6 ms |
27480 KB |
Output is correct |
25 |
Correct |
5 ms |
27228 KB |
Output is correct |
26 |
Correct |
6 ms |
27224 KB |
Output is correct |
27 |
Correct |
6 ms |
27224 KB |
Output is correct |
28 |
Correct |
6 ms |
27228 KB |
Output is correct |
29 |
Correct |
5 ms |
27228 KB |
Output is correct |
30 |
Correct |
6 ms |
27260 KB |
Output is correct |
31 |
Correct |
6 ms |
27272 KB |
Output is correct |
32 |
Correct |
5 ms |
27276 KB |
Output is correct |
33 |
Correct |
6 ms |
27320 KB |
Output is correct |