# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
579166 |
2022-06-18T12:37:07 Z |
lcj |
Two Dishes (JOI19_dishes) |
C++17 |
|
144 ms |
20504 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;
struct Dish {
ll a, s, p;
};
vector<Dish> d1, d2;
vector<ll> p1, p2, po1, po2;
ll getTime(int i1, int i2) {
return p1[i1]+p2[i2];
}
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(n+1, 0);
int t1, t2;
for (int i = 0; i < n; i++)
{
cin >> a >> s >> p;
Dish dd = Dish {a, s, p};
d1.push_back(dd);
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;
Dish dd = Dish {a, s, p};
d2.push_back(dd);
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;
ll tnow = p1[i]+p2[idx];
int ri = i;
if (idx == m) {
ri = upper_bound(p1.begin(), p1.end(), t1-p2[idx])-p1.begin()-1;
}
if (!iset) cmax = po1[ri]+po2[idx];
cmax = max(cmax, po1[ri]+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:50: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]
50 | if (p1[i] > t1) continue;
dishes.cpp:52:12: warning: unused variable 'tnow' [-Wunused-variable]
52 | ll tnow = p1[i]+p2[idx];
| ^~~~
dishes.cpp:29:13: warning: unused variable 't2' [-Wunused-variable]
29 | int t1, t2;
| ^~
dishes.cpp:50:21: warning: 't1' may be used uninitialized in this function [-Wmaybe-uninitialized]
50 | if (p1[i] > t1) continue;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
20504 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 |
144 ms |
20504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
20504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |