이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 << "\n";
return 0;
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |