Submission #991907

#TimeUsernameProblemLanguageResultExecution timeMemory
991907horezusholSoccer (JOI17_soccer)C++14
5 / 100
2 ms3932 KiB
#include<bits/stdc++.h> #define debug(x) cout << "\033[36m"<< __LINE__ << ":\033[39m " << (#x) << " = " << (x) << '\n' #define F first #define S second const char nl = '\n'; using namespace std; using ll = long long; ll h, w; ll A, B, C; ll n; vector<pair<ll, ll>> vp(100010); ll dp[510][510]; ll dist(ll x, ll y, ll X, ll Y) { return abs(x - X) + abs(y - Y); } ll shoot(ll x, ll y, ll X, ll Y) { ll res1 = abs(x - X)*C; ll res2 = abs(y - Y)*C; res1 += A*dist(X, y, X, Y) + B; res2 += A*dist(x, Y, X, Y) + B; // cout << abs(x - X) << " " << dist(X, y, X, Y) << nl; // cout << abs(y - Y) << " " << dist(x, Y, X, Y) << nl; return min(res1, res2); } void solve() { cin >> h >> w; cin >> A >> B >> C; cin >> n; for (ll i = 1; i <= n; i ++) { cin >> vp[i].F >> vp[i].S; } for (ll i = 0; i <= 500; i ++) { for (ll j = 0; j <= 500; j ++) { dp[i][j] = dist(vp[1].F, vp[1].S, i, j) * C; } } cout << min({dp[vp[2].F][vp[2].S], shoot(vp[1].F, vp[1].S, vp[2].F, vp[2].S)}); } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll tst = 1; // cin >> tst; while (tst --) { solve(); cout << nl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...