Submission #963896

# Submission time Handle Problem Language Result Execution time Memory
963896 2024-04-16T02:10:53 Z Tuanlinh123 Two Dishes (JOI19_dishes) C++17
10 / 100
10000 ms 39620 KB
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n, m, sum=0; cin >> n >> m;
    vector <ll> a(n), s(n), p(n), b(m), t(m), q(m);
    vector <vector <pll>> H(n);
    for (ll i=0; i<n; i++) cin >> a[i] >> s[i] >> p[i];
    for (ll j=0; j<m; j++) cin >> b[j] >> t[j] >> q[j];
    for (ll i=1; i<n; i++) a[i]+=a[i-1];
    for (ll i=1; i<m; i++) b[i]+=b[i-1];
    for (ll i=0; i<n; i++)
    {
        if (s[i]-a[i]<0) continue; sum+=p[i];
        ll pos=lower_bound(b.begin(), b.end(), s[i]-a[i]+1)-b.begin();
        if (pos<m) H[i].pb({pos+1, -p[i]});
    }
    for (ll i=0; i<m; i++)
    {
        if (t[i]-b[i]<0) continue;
        ll pos=lower_bound(a.begin(), a.end(), t[i]-b[i]+1)-a.begin();
        if (pos<n) H[pos].pb({i+1, q[i]});
        else sum+=q[i];
    }
    vector <ll> ans(m+1, sum);
    for (ll i=0; i<n; i++)
    {
        for (auto [p, w]:H[i])
            for (ll j=p; j<=m; j++)
                ans[j]+=w;
        for (ll j=1; j<=m; j++)
            ans[j]=max(ans[j], ans[j-1]);
    }
    cout << ans[m];
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:25:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   25 |         if (s[i]-a[i]<0) continue; sum+=p[i];
      |         ^~
dishes.cpp:25:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   25 |         if (s[i]-a[i]<0) continue; sum+=p[i];
      |                                    ^~~
# Verdict Execution time Memory Grader output
1 Execution timed out 10069 ms 39620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 16 ms 776 KB Output is correct
18 Correct 14 ms 604 KB Output is correct
19 Correct 15 ms 836 KB Output is correct
20 Correct 13 ms 756 KB Output is correct
21 Correct 13 ms 856 KB Output is correct
22 Correct 16 ms 728 KB Output is correct
23 Correct 14 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 16 ms 776 KB Output is correct
18 Correct 14 ms 604 KB Output is correct
19 Correct 15 ms 836 KB Output is correct
20 Correct 13 ms 756 KB Output is correct
21 Correct 13 ms 856 KB Output is correct
22 Correct 16 ms 728 KB Output is correct
23 Correct 14 ms 604 KB Output is correct
24 Execution timed out 10043 ms 32844 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 16 ms 776 KB Output is correct
18 Correct 14 ms 604 KB Output is correct
19 Correct 15 ms 836 KB Output is correct
20 Correct 13 ms 756 KB Output is correct
21 Correct 13 ms 856 KB Output is correct
22 Correct 16 ms 728 KB Output is correct
23 Correct 14 ms 604 KB Output is correct
24 Execution timed out 10043 ms 32844 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 16 ms 776 KB Output is correct
18 Correct 14 ms 604 KB Output is correct
19 Correct 15 ms 836 KB Output is correct
20 Correct 13 ms 756 KB Output is correct
21 Correct 13 ms 856 KB Output is correct
22 Correct 16 ms 728 KB Output is correct
23 Correct 14 ms 604 KB Output is correct
24 Execution timed out 10043 ms 32844 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10069 ms 39620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10069 ms 39620 KB Time limit exceeded
2 Halted 0 ms 0 KB -