Submission #578387

# Submission time Handle Problem Language Result Execution time Memory
578387 2022-06-16T13:55:02 Z Johann Two Dishes (JOI19_dishes) C++14
0 / 100
142 ms 9640 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int,int>
#define tiii tuple<int,int,int>
#define vi vector<int>
#define vpii vector<pii>
#define vtiii vector<tiii>
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()

const int MAXN = 1e6 + 7;
ll N,M;
ll A[MAXN],B[MAXN],S[MAXN],T[MAXN],P[MAXN],Q[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N >> M;
    for (int i = 0; i < N; ++i) cin >> A[i] >> S[i] >> P[i];
    for (int i = 0; i < M; ++i) cin >> B[i] >> T[i] >> Q[i];

    ll total = accumulate(A, A+N, 0) + accumulate(B, B+M, 0);

    ll ans = 0;
    int a = N-1, b = M-1;
    while (a >= 0 || b >= 0) {
        bool useA;
        if (a == -1) useA = false;
        else if (b == -1) useA = true;
        else {
            if (total <= S[a]) {
                useA = true;
            } else if (total <= T[b]) {
                useA = false;
            } else {
                useA = (A[a] >= B[b]);
            }
        }
        if (useA) {
            if (total <= S[a]) ans += P[a];
            total -= A[a];
            --a;
        } else {
            if (total <= T[b]) ans += Q[b];
            total -= B[b];
            --b;
        }
    }

    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 9640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 9640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 9640 KB Output isn't correct
2 Halted 0 ms 0 KB -