From 3d9b4c9af4d76c6df2dbb5a54cc0e5eb26906322 Mon Sep 17 00:00:00 2001 From: Ta180m Date: Sat, 15 Feb 2020 17:10:26 -0600 Subject: Create photo.cpp --- 2011/December/Gold/photo.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 2011/December/Gold/photo.cpp diff --git a/2011/December/Gold/photo.cpp b/2011/December/Gold/photo.cpp new file mode 100644 index 0000000..3492b8c --- /dev/null +++ b/2011/December/Gold/photo.cpp @@ -0,0 +1,22 @@ +#include +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 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'; +} -- cgit v1.2.3-70-g09d2