답안 #955794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955794 2024-03-31T12:26:08 Z vjudge1 Pinball (JOI14_pinball) C++17
11 / 100
1000 ms 8280 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

int m,n,rez=1e18;
int a[205],b[205],c[205],d[205];

bool func(vector<int> uredi){
    int topcinja[n+1];
    for (int i=1;i<=n;i++)
        topcinja[i]=1;
    for (auto x:uredi){
        for (int i=a[x];i<=b[x];i++)
            if (topcinja[i]==1)
                topcinja[i]=0, topcinja[c[x]]=1;
    }
    int br=0;
        for (int i=1;i<=n;i++){
            if (topcinja[i]) br++;
        }
    if (br==1) return true;
    return false;
}

void f(int red, int cena, vector<int> zemeni){
    if (red==m+1) {
        if (func(zemeni)) rez=min(rez,cena);
        return;
    }
    f(red+1,cena,zemeni);
    zemeni.push_back(red);
    f(red+1, cena+d[red], zemeni);
}

int32_t main()
{
    cin >> m >> n;
    for (int i=1;i<=m;i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    f(1,0,{});
    if (rez==1e18) cout << -1;
    else cout << rez;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Execution timed out 1008 ms 8280 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Execution timed out 1008 ms 8280 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Execution timed out 1008 ms 8280 KB Time limit exceeded
10 Halted 0 ms 0 KB -