Submission #927061

#TimeUsernameProblemLanguageResultExecution timeMemory
927061vjudge1 Martian DNA (BOI18_dna)C++17
100 / 100
66 ms35404 KiB
// 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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...