답안 #861011

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861011 2023-10-15T06:31:40 Z rati Poklon (COCI17_poklon) C++14
0 / 140
684 ms 11536 KB
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N, Q;
    cin >> N >> Q;

    vector<int> array(N);
    for (int i = 0; i < N; i++) {
        cin >> array[i];
    }

    unordered_map<int, int> count;
    for (int num : array) {
        count[num]++;
    }

    vector<int> prefixCount(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        prefixCount[i] = prefixCount[i - 1] + (count[array[i - 1]] == 2 ? 1 : 0);
    }

    for (int q = 0; q < Q; q++) {
        int L, R;
        cin >> L >> R;

        int result = prefixCount[R] - prefixCount[L - 1];
        cout << result << endl;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Incorrect 7 ms 348 KB Output isn't correct
5 Incorrect 127 ms 2228 KB Output isn't correct
6 Incorrect 133 ms 2160 KB Output isn't correct
7 Incorrect 258 ms 4436 KB Output isn't correct
8 Incorrect 405 ms 7156 KB Output isn't correct
9 Incorrect 539 ms 9300 KB Output isn't correct
10 Incorrect 684 ms 11536 KB Output isn't correct