# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
861037 | 2023-10-15T07:28:13 Z | guagua0407 | Two Dishes (JOI19_dishes) | C++17 | 505 ms | 1048576 KB |
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int mxn=1e6+5; ll a[mxn],S[mxn],Q[mxn]; ll b[mxn],T[mxn],P[mxn]; int pa[mxn],pb[mxn]; vector<int> qa[mxn],qb[mxn]; int n,m; int main() {_ 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<=n;i++){ int pos=upper_bound(b,b+m+1,S[i]-a[i])-b-1; pa[i]=pos; if(pos>=0) qa[pos].push_back(i); } for(int i=1;i<=m;i++){ int pos=upper_bound(a,a+n+1,T[i]-b[i])-a-1; pb[i]=pos; if(pos>=0) qb[pos].push_back(i); } vector<vector<ll>> dp(n+1,vector<ll>(m+1,-1e18)); dp[0][0]=0; for(int i=0;i<=n;i++){ for(int j=0;j<=m;j++){ if(i>0) dp[i][j]=max(dp[i][j],dp[i-1][j]+(pa[i]>=j?P[i]:0)); if(j>0) dp[i][j]=max(dp[i][j],dp[i][j-1]+(pb[j]>=i?Q[j]:0)); } } cout<<dp[n][m]; return 0; } //maybe its multiset not set
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 505 ms | 1048576 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 62040 KB | Output is correct |
2 | Correct | 12 ms | 62044 KB | Output is correct |
3 | Correct | 13 ms | 62044 KB | Output is correct |
4 | Correct | 12 ms | 62124 KB | Output is correct |
5 | Correct | 12 ms | 62044 KB | Output is correct |
6 | Correct | 12 ms | 62188 KB | Output is correct |
7 | Correct | 12 ms | 62040 KB | Output is correct |
8 | Correct | 12 ms | 62148 KB | Output is correct |
9 | Correct | 12 ms | 62040 KB | Output is correct |
10 | Correct | 14 ms | 62164 KB | Output is correct |
11 | Correct | 13 ms | 62040 KB | Output is correct |
12 | Correct | 12 ms | 62040 KB | Output is correct |
13 | Correct | 12 ms | 62044 KB | Output is correct |
14 | Correct | 13 ms | 62044 KB | Output is correct |
15 | Correct | 12 ms | 62040 KB | Output is correct |
16 | Correct | 13 ms | 62044 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 62040 KB | Output is correct |
2 | Correct | 12 ms | 62044 KB | Output is correct |
3 | Correct | 13 ms | 62044 KB | Output is correct |
4 | Correct | 12 ms | 62124 KB | Output is correct |
5 | Correct | 12 ms | 62044 KB | Output is correct |
6 | Correct | 12 ms | 62188 KB | Output is correct |
7 | Correct | 12 ms | 62040 KB | Output is correct |
8 | Correct | 12 ms | 62148 KB | Output is correct |
9 | Correct | 12 ms | 62040 KB | Output is correct |
10 | Correct | 14 ms | 62164 KB | Output is correct |
11 | Correct | 13 ms | 62040 KB | Output is correct |
12 | Correct | 12 ms | 62040 KB | Output is correct |
13 | Correct | 12 ms | 62044 KB | Output is correct |
14 | Correct | 13 ms | 62044 KB | Output is correct |
15 | Correct | 12 ms | 62040 KB | Output is correct |
16 | Correct | 13 ms | 62044 KB | Output is correct |
17 | Correct | 40 ms | 93532 KB | Output is correct |
18 | Correct | 38 ms | 93532 KB | Output is correct |
19 | Correct | 40 ms | 93636 KB | Output is correct |
20 | Correct | 38 ms | 91224 KB | Output is correct |
21 | Correct | 39 ms | 92452 KB | Output is correct |
22 | Correct | 42 ms | 93680 KB | Output is correct |
23 | Correct | 40 ms | 93532 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 62040 KB | Output is correct |
2 | Correct | 12 ms | 62044 KB | Output is correct |
3 | Correct | 13 ms | 62044 KB | Output is correct |
4 | Correct | 12 ms | 62124 KB | Output is correct |
5 | Correct | 12 ms | 62044 KB | Output is correct |
6 | Correct | 12 ms | 62188 KB | Output is correct |
7 | Correct | 12 ms | 62040 KB | Output is correct |
8 | Correct | 12 ms | 62148 KB | Output is correct |
9 | Correct | 12 ms | 62040 KB | Output is correct |
10 | Correct | 14 ms | 62164 KB | Output is correct |
11 | Correct | 13 ms | 62040 KB | Output is correct |
12 | Correct | 12 ms | 62040 KB | Output is correct |
13 | Correct | 12 ms | 62044 KB | Output is correct |
14 | Correct | 13 ms | 62044 KB | Output is correct |
15 | Correct | 12 ms | 62040 KB | Output is correct |
16 | Correct | 13 ms | 62044 KB | Output is correct |
17 | Correct | 40 ms | 93532 KB | Output is correct |
18 | Correct | 38 ms | 93532 KB | Output is correct |
19 | Correct | 40 ms | 93636 KB | Output is correct |
20 | Correct | 38 ms | 91224 KB | Output is correct |
21 | Correct | 39 ms | 92452 KB | Output is correct |
22 | Correct | 42 ms | 93680 KB | Output is correct |
23 | Correct | 40 ms | 93532 KB | Output is correct |
24 | Runtime error | 450 ms | 1048576 KB | Execution killed with signal 9 |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 62040 KB | Output is correct |
2 | Correct | 12 ms | 62044 KB | Output is correct |
3 | Correct | 13 ms | 62044 KB | Output is correct |
4 | Correct | 12 ms | 62124 KB | Output is correct |
5 | Correct | 12 ms | 62044 KB | Output is correct |
6 | Correct | 12 ms | 62188 KB | Output is correct |
7 | Correct | 12 ms | 62040 KB | Output is correct |
8 | Correct | 12 ms | 62148 KB | Output is correct |
9 | Correct | 12 ms | 62040 KB | Output is correct |
10 | Correct | 14 ms | 62164 KB | Output is correct |
11 | Correct | 13 ms | 62040 KB | Output is correct |
12 | Correct | 12 ms | 62040 KB | Output is correct |
13 | Correct | 12 ms | 62044 KB | Output is correct |
14 | Correct | 13 ms | 62044 KB | Output is correct |
15 | Correct | 12 ms | 62040 KB | Output is correct |
16 | Correct | 13 ms | 62044 KB | Output is correct |
17 | Correct | 40 ms | 93532 KB | Output is correct |
18 | Correct | 38 ms | 93532 KB | Output is correct |
19 | Correct | 40 ms | 93636 KB | Output is correct |
20 | Correct | 38 ms | 91224 KB | Output is correct |
21 | Correct | 39 ms | 92452 KB | Output is correct |
22 | Correct | 42 ms | 93680 KB | Output is correct |
23 | Correct | 40 ms | 93532 KB | Output is correct |
24 | Runtime error | 450 ms | 1048576 KB | Execution killed with signal 9 |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 62040 KB | Output is correct |
2 | Correct | 12 ms | 62044 KB | Output is correct |
3 | Correct | 13 ms | 62044 KB | Output is correct |
4 | Correct | 12 ms | 62124 KB | Output is correct |
5 | Correct | 12 ms | 62044 KB | Output is correct |
6 | Correct | 12 ms | 62188 KB | Output is correct |
7 | Correct | 12 ms | 62040 KB | Output is correct |
8 | Correct | 12 ms | 62148 KB | Output is correct |
9 | Correct | 12 ms | 62040 KB | Output is correct |
10 | Correct | 14 ms | 62164 KB | Output is correct |
11 | Correct | 13 ms | 62040 KB | Output is correct |
12 | Correct | 12 ms | 62040 KB | Output is correct |
13 | Correct | 12 ms | 62044 KB | Output is correct |
14 | Correct | 13 ms | 62044 KB | Output is correct |
15 | Correct | 12 ms | 62040 KB | Output is correct |
16 | Correct | 13 ms | 62044 KB | Output is correct |
17 | Correct | 40 ms | 93532 KB | Output is correct |
18 | Correct | 38 ms | 93532 KB | Output is correct |
19 | Correct | 40 ms | 93636 KB | Output is correct |
20 | Correct | 38 ms | 91224 KB | Output is correct |
21 | Correct | 39 ms | 92452 KB | Output is correct |
22 | Correct | 42 ms | 93680 KB | Output is correct |
23 | Correct | 40 ms | 93532 KB | Output is correct |
24 | Runtime error | 450 ms | 1048576 KB | Execution killed with signal 9 |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 505 ms | 1048576 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 505 ms | 1048576 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |