답안 #109019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
109019 2019-05-04T03:35:09 Z tictaccat Two Dishes (JOI19_dishes) C++14
5 / 100
738 ms 60960 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX = 1e6 + 100;

int N,M;
vector<int> A(MAX), S(MAX), P(MAX);
vector<int> B(MAX), T(MAX), Q(MAX);

main() {

    cin >> N >> M;

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

    int pB = M;
    int sumB = accumulate(B.begin()+1,B.begin()+M+1,0LL);
    int valB = accumulate(Q.begin()+1,Q.begin()+M+1,0LL);

    int sumA = 0;;
    int valA = 0;

    int res = 0;

    for (int pA = 0; pA <= N; pA++) {
        sumA += A[pA];
        valA += P[pA];
        while (pB >= 0 && sumA + sumB > S[1]) {
            sumB -= B[pB];
            valB -= Q[pB];
            pB--;
        }
       // cout << pA << " " << pB << " " << " " << sumB << " " << valB << "\n";
        if (sumA + sumB <= S[1]) {
            //cout << pA << " " << pB << "\n";
            res = max(res,valA+valB);
        }
    }

    cout << res << "\n";

    return 0;
}

Compilation message

dishes.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 688 ms 60664 KB Output is correct
2 Correct 738 ms 60960 KB Output is correct
3 Correct 663 ms 57420 KB Output is correct
4 Correct 736 ms 58344 KB Output is correct
5 Correct 43 ms 47352 KB Output is correct
6 Correct 678 ms 58224 KB Output is correct
7 Correct 359 ms 53212 KB Output is correct
8 Correct 385 ms 53112 KB Output is correct
9 Correct 640 ms 58080 KB Output is correct
10 Correct 460 ms 52856 KB Output is correct
11 Correct 416 ms 52900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 47352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 47352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 47352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 47352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 47352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 688 ms 60664 KB Output is correct
2 Correct 738 ms 60960 KB Output is correct
3 Correct 663 ms 57420 KB Output is correct
4 Correct 736 ms 58344 KB Output is correct
5 Correct 43 ms 47352 KB Output is correct
6 Correct 678 ms 58224 KB Output is correct
7 Correct 359 ms 53212 KB Output is correct
8 Correct 385 ms 53112 KB Output is correct
9 Correct 640 ms 58080 KB Output is correct
10 Correct 460 ms 52856 KB Output is correct
11 Correct 416 ms 52900 KB Output is correct
12 Incorrect 39 ms 47352 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 688 ms 60664 KB Output is correct
2 Correct 738 ms 60960 KB Output is correct
3 Correct 663 ms 57420 KB Output is correct
4 Correct 736 ms 58344 KB Output is correct
5 Correct 43 ms 47352 KB Output is correct
6 Correct 678 ms 58224 KB Output is correct
7 Correct 359 ms 53212 KB Output is correct
8 Correct 385 ms 53112 KB Output is correct
9 Correct 640 ms 58080 KB Output is correct
10 Correct 460 ms 52856 KB Output is correct
11 Correct 416 ms 52900 KB Output is correct
12 Incorrect 39 ms 47352 KB Output isn't correct
13 Halted 0 ms 0 KB -