# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
768394 | nguyentunglam | Team Contest (JOI22_team) | C++17 | 2068 ms | 4336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 2e5 + 10;
int a[3][N], mx[3];
bool ban[N];
int main() {
#define task ""
cin.tie(0) -> sync_with_stdio(0);
if (fopen ("task.inp", "r")) {
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
}
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int n; cin >> n;
for(int i = 1; i <= n; i++) for(int j = 0; j < 3; j++) cin >> a[j][i];
int cur = n;
while (cur >= 3) {
mx[0] = mx[1] = mx[2] = 0;
for(int i = 1; i <= n; i++) for(int j = 0; j < 3; j++) if (!ban[i]) mx[j] = max(mx[j], a[j][i]);
bool stop = 1;
for(int i = 1; i <= n; i++) if (!ban[i]) {
int same = 0;
for(int j = 0; j < 3; j++) same += mx[j] == a[j][i];
if (same >= 2) ban[i] = 1, stop = 0, cur--;
}
if (stop) {
// for(int i = 1; i <= n; i++) cout << ban[i] << endl;
cout << mx[0] + mx[1] + mx[2];
return 0;
}
}
cout << -1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |