답안 #780142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780142 2023-07-12T06:55:54 Z Cookie Martian DNA (BOI18_dna) C++14
0 / 100
33 ms 3468 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 998244353;
const int mxn = 2e5 + 5, mxq = 2e5 + 5, sq = 400, mxv = 2e7 + 5;
//const int base = (1 << 18);
const ll inf = 1e9, neg = -69420;
int n, k, r, cnt;
int cc[mxn + 1], a[mxn + 1], val[mxn + 1];
void add(int x){
    cc[a[x]]++;
    if(val[a[x]] && cc[a[x]] == val[a[x]])cnt++;
}
void rem(int x){
    if(val[a[x]] && cc[a[x]] == val[a[x]])cnt--;
    cc[a[x]]--;
}
signed main(){
    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];
    for(int i = 0; i < k; i++){
        int id, v; cin >> id >> v;
        val[id] = v;
    }
    cnt = k - r;
    int rp = 1, ans = inf;
    for(int i = 1; i <= n; i++){
        if(i > 1){
            rem(i - 1);
        }else{
            while(cnt != k && rp <= n){
                add(rp++);
                
            }
        }
        if(cnt == k)ans = min(ans, rp - i);
    }
    if(ans == inf){
        cout << "Impossible";
    }else{
        cout << ans;
    }
    return(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 3468 KB Output isn't correct
2 Halted 0 ms 0 KB -