Submission #581394

#TimeUsernameProblemLanguageResultExecution timeMemory
581394VanillaPinball (JOI14_pinball)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int64; const int maxn = 1e5 + 2; int64 l[maxn], r[maxn], c[maxn], cost[maxn]; int main() { int n,m; cin >> n >> m; for (int i = 0; i < n; i++){ cin >> l[i] >> r[i] >> c[i] >> cost[i]; } int64 ans = 1e18; for (int i = 0; i < n; i++){ int64 tans = cost[i]; int64 il = l[i], ir = r[i]; for (int j = i - 1; j >= 0; j--){ if (c[j] >= il && c[j] <= ir) { if (l[j] < il || r[j] > ir) { tans+=cost[j]; il = min(il, l[j]); ir = max(ir, r[j]); } } else { tans = 1e18; break; } } if (il == 1 && ir == m) ans = min(ans, tans); } cout << (ans == 1e18 ? -1: ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...