답안 #708646

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708646 2023-03-12T06:23:49 Z PixelCat Two Dishes (JOI19_dishes) C++14
0 / 100
2 ms 468 KB
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define eb emplace_back
#define int LL
using namespace std;
using LL = long long;
using pii = pair<int, int>;

const int MAXN = 1000010;

struct OWO {
    int a, s, p;
};
OWO a[MAXN];
OWO b[MAXN];

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // NYA =^-w-^=
    int n, m; cin >> n >> m;
    int nowt = 0;
    For(i, 1, n) {
        auto &owo = a[i];
        cin >> owo.a >> owo.s >> owo.p;
        assert(owo.p == 1);
        nowt += owo.a;
    }
    For(i, 1, m) {
        auto &owo = b[i];
        cin >> owo.a >> owo.s >> owo.p;
        assert(owo.p == 1);
        nowt += owo.a;
    }
    int i = n, j = m;
    int ans = 0;
    while(i || j) {
        int sel = -1; // 1 for a, 2 for b
        if(i == 0) sel = 2;
        else if(j == 0) sel = 1;
        else if(nowt <= a[i].s) sel = 1;
        else if(nowt <= b[j].s) sel = 2;
        else if(a[i].a > b[i].a) sel = 1;
        else sel = 2;

        if(sel == 1) {
            ans += (nowt <= a[i].s);
            nowt -= a[i].a;
            i--;
        } else {
            ans += (nowt <= b[j].s);
            nowt -= b[j].a;
            j--;
        }
    }
    cout << ans << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Incorrect 1 ms 328 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Incorrect 1 ms 328 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Incorrect 1 ms 328 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Incorrect 1 ms 328 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Incorrect 1 ms 328 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -