#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
#define mp make_pair
#define f first
#define s second
int H, W;
ll A, B, C;
const int mx = 100005;
int N;
pi ST[mx];
ll KICK(pi a, pi b){
int xdist = abs(a.f-b.f);
int ydist = abs(a.s-b.s);
return min(C*(xdist+ydist), B+A*(max(xdist, ydist))+C*(min(xdist, ydist)));
}
int main(){
cin >> H >> W;
cin >> A >> B >> C;
cin >> N;
for(int i = 1; i <= N; i++){
cin >> ST[i].f >> ST[i].s;
}
if(N == 2){
ll ans = KICK(ST[1], ST[2]);
cout << ans << "\n";
exit(0);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |