제출 #266296

#제출 시각아이디문제언어결과실행 시간메모리
266296dolphingarlicTwo Dishes (JOI19_dishes)C++14
10 / 100
10029 ms26360 KiB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll a[200001], b[200001], s[200001], t[200001], p[200001], q[200001];
ll dp[2][200001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> s[i] >> p[i];
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i] >> t[i] >> q[i];
        b[i] += b[i - 1];
    }
    for (int i = 1; i <= m; i++) dp[0][i] = dp[0][i - 1] + q[i] * (b[i] <= t[i]);
    for (int i = 1; i <= n; i++) {
        dp[i & 1][0] = dp[i - 1 & 1][0] + p[i] * (a[i] <= s[i]);
        for (int j = 1; j <= m; j++) {
            dp[i & 1][j] = max(dp[i - 1 & 1][j] + p[i] * (a[i] + b[j] <= s[i]),
                           dp[i & 1][j - 1] + q[j] * (a[i] + b[j] <= t[j]));
        }
    }
    cout << dp[n & 1][m];
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

dishes.cpp: In function 'int main()':
dishes.cpp:23:29: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   23 |         dp[i & 1][0] = dp[i - 1 & 1][0] + p[i] * (a[i] <= s[i]);
      |                           ~~^~~
dishes.cpp:25:37: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   25 |             dp[i & 1][j] = max(dp[i - 1 & 1][j] + p[i] * (a[i] + b[j] <= s[i]),
      |                                   ~~^~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...