Submission #40356

#TimeUsernameProblemLanguageResultExecution timeMemory
40356krauchPinball (JOI14_pinball)C++14
51 / 100
1057 ms2284 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair < int, int > PII; #define F first #define S second #define mkp make_pair #define eb emplace_back #define all(a) a.begin(), a.end() #define sz(a) (int)a.size() #define forn(x, a, b) for (int x = a; x <= b; ++x) #define for1(x, a, b) for (int x = a; x >= b; --x) const ll ool = 1e18 + 9; const int N = 3e5 + 3, oo = 1e9 + 9; int n, m, a[N], b[N], c[N], cost[N]; ll d[N], ans = ool; int main() { #ifdef krauch freopen("input.txt", "r", stdin); #endif scanf("%d%d", &m, &n); forn(i, 1, m) { scanf("%d%d%d%d", a + i, b + i, c + i, cost + i); cost[2 * m - i + 1] = cost[i]; a[2 * m - i + 1] = a[i]; b[2 * m - i + 1] = b[i]; c[2 * m - i + 1] = c[i]; } forn(i, 1, m) { d[i] = ool; if (a[i] == 1) d[i] = cost[i]; forn(j, 1, i - 1) { if (a[i] <= c[j] && c[j] <= b[i]) d[i] = min(d[i], d[j] + cost[i]); } d[2 * m - i + 1] = d[i]; } forn(i, m + 1, 2 * m) { forn(j, m + 1, i - 1) { if (a[j] <= c[i] && c[i] <= b[j]) d[i] = min(d[i], d[j] + cost[i]); } if (b[i] == n) ans = min(ans, d[i]); } cout << (ans == ool ? -1 : ans) << "\n"; return 0; }

Compilation message (stderr)

pinball.cpp: In function 'int main()':
pinball.cpp:28:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &m, &n);
                          ^
pinball.cpp:30:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d%d", a + i, b + i, c + i, cost + i);
                                                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...