System Testing
62 / 62
AC
62/62 test cases passed
Submission #24
| Problem | TheSimpleGame |
|---|---|
| Handle | Nur Ahmad Wahid |
| Submitted | 2026-07-24 02:21:52 |
Source Code
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define ll long long
const int INF = 1e9;
const ll LINF = 1e18;
class TheSimpleGame {
public:
int count(int n, vector<int> x, vector<int> y)
{
int num = x.size();
int totalCost = 0;
for (int i=0;i<num;i++) {
int costTo1 = abs(x[i] - 1) + abs(y[i] - 1);
int costToNN = abs(x[i] - n) + abs(y[i] - n);
int costTo1N = abs(x[i] - 1) + abs(y[i] - n);
int costToN1 = abs(x[i] - n) + abs(y[i] - 1);
int minCost = min(costTo1, min(costToNN, min(costTo1N, costToN1)));
totalCost += minCost;
}
return totalCost;
}
};