Submission #245296

#TimeUsernameProblemLanguageResultExecution timeMemory
245296thecodingwizardPinball (JOI14_pinball)C++11
51 / 100
1091 ms2040 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll inf = 1e18; int main() { int m, n; cin >> m >> n; int L[m], R[m], T[m], C[m]; for (int i = 0; i < m; i++) cin >> L[i] >> R[i] >> T[i] >> C[i]; ll dpLeft[m], dpRight[m]; for (int i = 0; i < m; i++) { dpLeft[i] = dpRight[i] = inf; if (L[i] == 1) dpLeft[i] = C[i]; if (R[i] == n) dpRight[i] = C[i]; for (int j = 0; j < i; j++) { if (L[i] <= T[j] && T[j] <= R[i]) { dpLeft[i] = min(dpLeft[i], dpLeft[j] + C[i]); dpRight[i] = min(dpRight[i], dpRight[j] + C[i]); } } } ll opt = inf; for (int i = 0; i < m; i++) { opt = min(opt, dpLeft[i] + dpRight[i] - C[i]); } if (opt == inf) cout << -1 << endl; else cout << opt << endl; 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...