diff options
author | Anthony Wang | 2022-03-15 20:38:51 -0500 |
---|---|---|
committer | Anthony Wang | 2022-03-15 20:38:51 -0500 |
commit | 896c6ceeff605c935a5538e3d9eca40ea3c79c56 (patch) | |
tree | 69d97b50f5ced801f6043cbef0219a941239f892 /11.5/mar/gold/restack.cpp | |
parent | 4c488e4c73f2d0e2b96bf0c444c05d42e566dd11 (diff) |
Restructure directories AGAIN so contests from the same season are in the same directory
Diffstat (limited to '11.5/mar/gold/restack.cpp')
-rw-r--r-- | 11.5/mar/gold/restack.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/11.5/mar/gold/restack.cpp b/11.5/mar/gold/restack.cpp new file mode 100644 index 0000000..49b325d --- /dev/null +++ b/11.5/mar/gold/restack.cpp @@ -0,0 +1,16 @@ +#include <bits/stdc++.h> +using namespace std; + +int main() { + ifstream cin("restack.in"); + ofstream cout("restack.out"); + int n, c = 0, ans = 0; cin >> n; + vector<int> v; + for (int i = 0; i < n; i++) { + int a, b; cin >> a >> b; + v.push_back(c += a - b); + } + sort(v.begin(), v.end()); + for (int i = 0; i < n; i++) ans += abs(v[i] - v[n / 2]); + cout << ans << '\n'; +} |