Submission #61216

#TimeUsernameProblemLanguageResultExecution timeMemory
61216Eae02Fireworks (APIO16_fireworks)C++14
0 / 100
3 ms488 KiB
#include <bits/stdc++.h> int main() { int numJ, numE; std::cin >> numJ; std::cin >> numE; if (numJ != 1) return 1; int minDelay = INT32_MAX; int maxDelay = 0; std::vector<int> delay(numE); for (int i = 0; i < numE; i++) { int n, l; std::cin >> n; std::cin >> l; if (i != 0) { minDelay = std::min(l, minDelay); maxDelay = std::min(l, maxDelay); delay[i - 1] = l; } } int minCost = INT32_MAX; for (int d = minDelay; d <= maxDelay; d++) { int cost = 0; for (int j = 0; j < numE; j++) { cost += std::abs(delay[j] - d); } minCost = std::min(minCost, cost); } std::cout << minCost << std::endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...