aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2020-10-06 17:31:42 -0500
committerAnthony Wang2020-10-06 17:31:42 -0500
commitb78869568ef8d97047749596dd1df43a6b9246e7 (patch)
tree1f110decb879286d85572a4c05e523a725d47cf8
parentac539fe4aa93fc68aff6661c616d3489645896d3 (diff)
Add poi.cpp
-rw-r--r--09/poi.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/09/poi.cpp b/09/poi.cpp
new file mode 100644
index 0000000..e16bf42
--- /dev/null
+++ b/09/poi.cpp
@@ -0,0 +1,46 @@
+#include <bits/stdc++.h>
+#define f first
+#define s second
+using namespace std;
+using ll = long long;
+using ii = pair<int, int>;
+constexpr int MX = 2005;
+
+bool B[MX][MX];
+int pt[MX], sc[MX], sv[MX], rk[MX];
+
+int main() {
+ if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
+ ios_base::sync_with_stdio(0), cin.tie(0);
+
+ int N, T, P; cin >> N >> T >> P;
+ for (int i = 0; i < N; ++i) {
+ for (int j = 0; j < T; ++j) cin >> B[i][j];
+ }
+
+ for (int i = 0; i < T; ++i) {
+ pt[i] = N;
+ for (int j = 0; j < N; ++j) pt[i] -= B[j][i];
+ }
+
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < T; ++j)
+ if (B[i][j]) sc[i] += pt[j], ++sv[i];
+
+ for (int i = 0; i < N; ++i) rk[i] = i;
+
+ sort(rk, rk+N, [&](int a, int b) {
+ if (sc[a] == sc[b]) {
+ if (sv[a] == sv[b]) return a < b;
+ return sv[a] > sv[b];
+ }
+ return sc[a] > sc[b];
+ });
+
+ for (int i = 0; i < N; ++i) {
+ if (rk[i] == P-1) {
+ cout << sc[rk[i]] << ' ' << i+1;
+ return 0;
+ }
+ }
+} \ No newline at end of file