Submission #595158

# Submission time Handle Problem Language Result Execution time Memory
595158 2022-07-13T12:06:48 Z piOOE Soccer (JOI17_soccer) C++17
0 / 100
1 ms 212 KB
#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];
    }
    if (a >= c) {
        cout << (abs(x[0] - x[n - 1]) + abs(y[0] - y[n - 1])) * c;
    } else {
        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 time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -