Submission #579229

# Submission time Handle Problem Language Result Execution time Memory
579229 2022-06-18T13:48:37 Z lcj Two Dishes (JOI19_dishes) C++17
0 / 100
142 ms 7992 KB
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int n, m;

vector<ll> p1, p2, po1, po2;

void solve() {
    cin >> n >> m;
    ll a, s, p;
    p1.assign(n+1, 0);
    p2.assign(m+1, 0);
    po1.assign(n+1, 0);
    po2.assign(m+1, 0);
    int t1;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> s >> p;
        p1[i+1] = p1[i]+a;
        po1[i+1] = po1[i]+p;
        t1 = s;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> a >> s >> p;
        p2[i+1] = p2[i]+a;
        po2[i+1] = po2[i]+p;
    }
    ll cmax = 0; 
    bool iset = 0;
    for (int i = 0; i <= n; i++)
    {
        if (p1[i] > t1) {continue;}
        int idx = upper_bound(p2.begin(), p2.end(), t1-p1[i])-p2.begin()-1;
        if (i != n && p1[i+1]+p2[idx] <= t1) continue;
        if (!iset) {
            cmax = po1[i]+po2[idx];
        }
        cmax = max(cmax, po1[i]+po2[idx]);
        iset = 1;
    }
    cout << cmax << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

Compilation message

dishes.cpp: In function 'void solve()':
dishes.cpp:38:19: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<long long unsigned int>, long long unsigned int>::value_type' {aka 'long long unsigned int'} and 'int' [-Wsign-compare]
   38 |         if (p1[i] > t1) {continue;}
dishes.cpp:40:39: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<long long unsigned int>, long long unsigned int>::value_type' {aka 'long long unsigned int'} and 'int' [-Wsign-compare]
   40 |         if (i != n && p1[i+1]+p2[idx] <= t1) continue;
dishes.cpp:38:21: warning: 't1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |         if (p1[i] > t1) {continue;}
      |                     ^~
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 7992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 7992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 7992 KB Output isn't correct
2 Halted 0 ms 0 KB -