제출 #883163

#제출 시각아이디문제언어결과실행 시간메모리
883163MilosMilutinovicLong Distance Coach (JOI17_coach)C++14
71 / 100
2056 ms17344 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long x, t; int n, m, w; cin >> x >> n >> m >> w >> t; vector<long long> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } s.push_back(x); n += 1; m += 1; vector<long long> d(m); vector<int> c(m); for (int i = 1; i < m; i++) { cin >> d[i] >> c[i]; } d[0] = 0; c[0] = 0; vector<int> order(m); iota(order.begin(), order.end(), 0); sort(order.begin(), order.end(), [&](int i, int j) { return d[i] < d[j]; }); { vector<long long> new_d(m); vector<int> new_c(m); for (int i = 0; i < m; i++) { new_d[i] = d[order[i]]; new_c[i] = c[order[i]]; } d = new_d; c = new_c; } const long long inf = (long long) 1e18; vector<long long> fir(m, inf); for (int i = 0; i < n; i++) { int low = 0, high = m - 1, idx = -1; while (low <= high) { int mid = low + high >> 1; if (d[mid] < (s[i] % t)) { idx = mid; low = mid + 1; } else { high = mid - 1; } } if (idx != -1) { fir[idx] = min(fir[idx], s[i] / t); } } vector<__int128> dp(m); dp[0] = (x / t + 1) * 1LL * w; for (int i = 1; i < m; i++) { dp[i] = dp[i - 1] + ((x - d[i]) / t + 1) * 1LL * w; if (fir[i] == inf) { continue; } __int128 sum_c = 0; for (int j = i; j > 0; j--) { sum_c += c[j]; dp[i] = min(dp[i], dp[j - 1] + sum_c + (__int128) (fir[i]) * 1LL * (i - j + 1) * 1LL * w); } } cout << (long long) dp[m - 1] << '\n'; return 0; }

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

coach.cpp: In function 'int main()':
coach.cpp:45:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   45 |       int mid = low + high >> 1;
      |                 ~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...