답안 #709478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709478 2023-03-13T16:48:43 Z stevancv Martian DNA (BOI18_dna) C++14
0 / 100
202 ms 141488 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 2e5 + 5;
const int inf = 1e9;
const int mod = 1e9 + 7;
deque<int> dq[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> b(m);
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x >> b[x];
    }
    set<int> s;
    int dobri = 0;
    int ans = 1e6;
    for (int i = 0; i < n; i++) {
        dq[a[i]].push_back(i);
        if (dq[a[i]].size() > b[a[i]]) {
            s.erase(dq[a[i]].front());
            dq[a[i]].pop_front();
            s.insert(dq[a[i]].front());
        }
        else if (dq[a[i]].size() == b[a[i]]) {
            s.insert(dq[a[i]].front());
            dobri += 1;
        }
        if (dobri == k) smin(ans, i - *s.begin() + 1);
    }
    if (ans == 1e6) cout << "impossible" << en;
    else cout << ans << en;
    return 0;
}

Compilation message

dna.cpp: In function 'int main()':
dna.cpp:31:29: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   31 |         if (dq[a[i]].size() > b[a[i]]) {
dna.cpp:36:34: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   36 |         else if (dq[a[i]].size() == b[a[i]]) {
# 결과 실행 시간 메모리 Grader output
1 Incorrect 83 ms 134860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 88 ms 134912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 114 ms 137004 KB Output is correct
2 Incorrect 111 ms 137580 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 202 ms 141488 KB Output is correct
2 Incorrect 185 ms 141216 KB Output isn't correct
3 Halted 0 ms 0 KB -