Submission #875555

#TimeUsernameProblemLanguageResultExecution timeMemory
875555NeroZeinFireworks (APIO16_fireworks)C++17
7 / 100
1 ms576 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define deb(...) #endif const int N = 5003; vector<pair<int, int>> g[N]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; for (int i = 2; i <= n + m; ++i) { int p, c; cin >> p >> c; g[p].emplace_back(i, c); } if (n == 1) { long long ans = 1e15; for (int i = 0; i < (int) g[1].size(); ++i) { long long res = 0; for (int j = 0; j < (int) g[1].size(); ++j) { res += abs(g[1][i].second - g[1][j].second); } ans = min(ans, res); } cout << ans << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...