답안 #963887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963887 2024-04-16T01:53:27 Z Tuanlinh123 Two Dishes (JOI19_dishes) C++17
0 / 100
10000 ms 39512 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, 0), 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]});
    }
    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];
      |                                    ^~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10074 ms 39512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10074 ms 39512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10074 ms 39512 KB Time limit exceeded
2 Halted 0 ms 0 KB -