제출 #958972

#제출 시각아이디문제언어결과실행 시간메모리
958972typ_ikPinball (JOI14_pinball)C++17
0 / 100
2 ms4440 KiB
#include <bits/stdc++.h> #define ll long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define watch(x) cout << (#x) << " : " << x << '\n' #define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; #define int ll const int N = 100100; int l[N], r[N], c[N], d[N]; ll pref[N], suf[N]; const ll INF = 1e16 + 128; void solve() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> l[i] >> r[i] >> c[i] >> d[i]; for (int i = 1; i <= m; i++) pref[i] = suf[i] = INF; pref[0] = 0; suf[m + 1] = 0; ll ans = INF; for (int i = 0; i < n; i++) { ll lx = INF, rx = INF; if (l[i] == 1) lx = 0; if (r[i] == m) rx = 0; for (int x = l[i]; x <= r[i]; x++) lx = min(lx, pref[x]), rx = min(rx, suf[x]); ans = min(ans, lx + rx + d[i]); if (l[i] == 1) pref[c[i]] = min(pref[c[i]], 1ll * d[i]); else for (int x = l[i]; x <= r[i]; x++) pref[c[i]] = min(pref[c[i]], pref[x] + d[i]); if (r[i] == m) suf[c[i]] = min(suf[c[i]], 1ll * d[i]); else for (int x = l[i]; x <= r[i]; x++) suf[c[i]] = min(suf[c[i]], pref[x] + d[i]); } if (ans >= INF) ans = -1; cout << ans << '\n'; } main() { boost; solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

pinball.cpp:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   58 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...