Submission #595160

#TimeUsernameProblemLanguageResultExecution timeMemory
595160piOOESoccer (JOI17_soccer)C++17
0 / 100
1 ms224 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int h, w, n; ll a, b, c; cin >> h >> w >> a >> b >> c >> n; vector<int> x(n), y(n); for (int i = 0; i < n; ++i) { cin >> x[i] >> y[i]; } int mx = max(h, w); for (int k = 1; k <= max(h, w); ++k) { if (c * k > a * k + b) { mx = k - 1; break; } } auto distance = [&](int i, int j) { int f = abs(x[i] - x[j]), s = abs(y[i] - y[j]); if (f < s) { swap(f, s); } return s * c + min(f, mx) * c + (f - min(f, mx)) * a + b; }; cout << distance(0, 1) << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...