답안 #555503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
555503 2022-05-01T06:18:50 Z AriaH Team Contest (JOI22_team) C++17
0 / 100
1 ms 340 KB
/* Im the best and i work like that */

#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

#define F first
#define S second
#define all(x) x.begin(),x.end()
#define Mp make_pair
#define point complex
#define endl '\n'
#define SZ(x) (int)x.size()
#define fast_io ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file_io freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define mashtali return cout << "Hello, World!", 0;

const int N = 1e6 + 10;
const int LOG = 20;
const ll mod = 1e9 + 7;
const ll inf = 8e18;
const double pi = acos(-1);
const ld eps = 1e-18;
const ld one = 1.;

ll pw(ll a, ll b, ll M, ll ret = 1) { if(a == 0) return 0; a %= M; while(b) { ret = (b & 1? ret * a % M : ret), a = a * a % M, b >>= 1; } return ret % M; }

mt19937 rng(time(nullptr));

int n, A[N], B[N], C[N];

int main()
{
	fast_io;
    set < pii > a, b, c;
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> A[i] >> B[i] >> C[i];
        a.insert(Mp(-A[i], i));
        b.insert(Mp(-B[i], i));
        c.insert(Mp(-C[i], i));
    }
    while(SZ(a))
    {
        pii aa = *a.begin();
        pii bb = *b.begin();
        pii cc = *c.begin();
        aa.F *= -1;
        bb.F *= -1;
        cc.F *= -1;
        ///cout << aa.F << " " << bb.F << " " << cc.F << endl;
        int id = aa.S;
        if(B[id] >= bb.F || C[aa.S] >= cc.F)
        {
            a.erase(Mp(-A[id], id));
            b.erase(Mp(-B[id], id));
            c.erase(Mp(-C[id], id));
            continue;
        }
        id = bb.S;
        if(A[id] >= aa.F || C[id] >= cc.F)
        {
            a.erase(Mp(-A[id], id));
            b.erase(Mp(-B[id], id));
            c.erase(Mp(-C[id], id));
            continue;
        }
        id = cc.S;
        if(A[id] >= aa.F || B[id] >= bb.F)
        {
            a.erase(Mp(-A[id], id));
            b.erase(Mp(-B[id], id));
            c.erase(Mp(-C[id], id));
            continue;
        }
        cout << aa.F + bb.F + cc.F << endl;
        return 0;
    }
	return 0;
}

/* check corner case(n = 1?), watch for negetive index or overflow */
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -