Submission #908882

#TimeUsernameProblemLanguageResultExecution timeMemory
908882vjudge1Pinball (JOI14_pinball)C++17
0 / 100
103 ms344 KiB
#include <iostream> using namespace std; pair<pair<int, int>, pair<int, int>> arr[20]; bool xd[10005]; int main() { int n, m, a, b, c, d; cin >> n >> m; for(int i=0; i<m; i++) { cin >> a >> b >> c >> d; arr[i] = {{a, b}, {c, d}}; } long long cost; long long res = 1000000000000000; int dd; for(int i=1; i<(1<<m); i++) { for(int j=0; j<=n; j++) { xd[j] = false; } cost = 0; for(int j=0; j<m; j++) { if(i & (1<<j)) { cost+=arr[j].second.second; for(int k = arr[j].first.first; k<=arr[j].first.second; k++) { xd[k] = true; } xd[arr[j].second.first] = false; } } dd = 0; for(int j=1; j<=n; j++) { if(xd[j] == false) { dd++; } } if(dd == 1) { res = min(res, cost); } } if(res != 1000000000000000) { cout << res; } else { cout << -1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...