Submission #768394

#TimeUsernameProblemLanguageResultExecution timeMemory
768394nguyentunglamTeam Contest (JOI22_team)C++17
64 / 100
2068 ms4336 KiB
#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)

team.cpp: In function 'int main()':
team.cpp:14:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen ("task.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:15:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen ("task.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:18:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:19:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...