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 | |
parent | 4c488e4c73f2d0e2b96bf0c444c05d42e566dd11 (diff) |
Restructure directories AGAIN so contests from the same season are in the same directory
Diffstat (limited to '11.5')
-rw-r--r-- | 11.5/dec/gold/photo.cpp | 22 | ||||
-rw-r--r-- | 11.5/mar/gold/restack.cpp | 16 |
2 files changed, 38 insertions, 0 deletions
diff --git a/11.5/dec/gold/photo.cpp b/11.5/dec/gold/photo.cpp new file mode 100644 index 0000000..3492b8c --- /dev/null +++ b/11.5/dec/gold/photo.cpp @@ -0,0 +1,22 @@ +#include <bits/stdc++.h> +using namespace std; + +int A[5][20005]; + +int main { + int N; + cin >> N; + for (int i = 0; i < 5; i++) { + for (int j = 0; j < N; j++) cin >> A[i][j]; + } + unordered_map<int, int> m[5]; + for (int i = 0; i < 5; i++) { + for (int j = 0; j < N; j++) m[i][A[i][j]] = j; + } + sort(A[0], A[0] + N, [&m](const int& a, const int& b) { + int c[2] = { 0 }; + for (int i = 0; i < 5; i++) c[m[i][a] < m[i][b]]++; + return c[0] < c[1]; + }); + for (int i = 0; i < N; i++) cout << A[0][i] << '\n'; +} 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'; +} |