#include <bits/stdc++.h>
int main()
{
int numJ, numE;
std::cin >> numJ;
std::cin >> numE;
if (numJ != 1)
return 1;
std::vector<int> delay(numE);
for (int i = 0; i < numE; i++)
{
int n, l;
std::cin >> n;
std::cin >> l;
if (i != 0)
{
delay[i - 1] = l;
}
}
int minCost = INT32_MAX;
for (int i = 0; i < numE; i++)
{
int cost = 0;
for (int j = 0; j < numE; j++)
{
cost += std::abs(delay[j] - delay[i]);
}
minCost = std::min(minCost, cost);
}
std::cout << minCost << std::endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
556 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |