답안 #828321

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
828321 2023-08-17T08:24:55 Z vjudge1 Martian DNA (BOI18_dna) C++17
40 / 100
2000 ms 13264 KB
#include<bits/stdc++.h>
#define se second
#define fi first
using namespace std;
const int nmax = 200002;
int N,K,R;
int arr[nmax];
map<int,int> tar;
int simp[4004];
pair<int,int> terms[nmax];
int countt[101][101][101]={0};
int hit[101]={0};
int main() {
    cin >> N >> K >> R;
    for(int i=1; i<=N; i++) {
        cin >> arr[i];
        hit[arr[i]]++;
    }
    bool impo=false;
    for(int i=1; i<=R; i++) {
        cin >> terms[i].fi >> terms[i].se;
        tar[terms[i].fi] = terms[i].se;
        if(hit[terms[i].fi]<terms[i].se) impo=true;
    }
    if(impo) {
        cout << "impossible" << endl;
        return 0;
    }
    int sem;
    int res=INT_MAX;
    for(int i=1; i<=N; i++) {
        sem = 0;
        memset(simp, 0, sizeof(simp));
        for(int j=i; j<=N; j++) {
            simp[arr[j]]++;
            if(tar.count(arr[j])>0) {
                if(simp[arr[j]]==tar[arr[j]]) {
                    sem++;
                }
            } 
            if(sem == R) {
                res = min(res, (j-i+1));
            }
        }
    }
    cout << res << endl;
    /*for(int i=1; i<=N; i++) {
        for(int j=i; j<=N; j++) {
            for(int k=i; k<=j; k++) {
                countt[i][j][arr[k]]++;
            }
        }
    }
    int shrtpath = INT_MAX;
    int k;
    int bisa;
    for(int i=1; i<=N; i++) {
        for(int j=i; j<=N; j++) {
            bisa=true;
            k=1;
            while(k<=R) {
                if(countt[i][j][terms[k].fi] < terms[k].se) {
                    bisa=false;
                    break;
                }
                k++;
            }
            if(bisa) {
                shrtpath = min(shrtpath, (j-i+1));
            }
        }
    }
    cout << shrtpath << endl;
    */
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 364 KB Output is correct
2 Correct 69 ms 344 KB Output is correct
3 Correct 77 ms 340 KB Output is correct
4 Correct 88 ms 340 KB Output is correct
5 Correct 85 ms 356 KB Output is correct
6 Correct 130 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2070 ms 1440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 106 ms 13264 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -