제출 #955788

#제출 시각아이디문제언어결과실행 시간메모리
955788vjudge1Pinball (JOI14_pinball)C++17
0 / 100
2 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int m,n,rez=INT_MAX; 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==INT_MAX) cout << -1; else cout << rez; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...