# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
579185 |
2022-06-18T12:48:13 Z |
lcj |
Two Dishes (JOI19_dishes) |
C++17 |
|
161 ms |
20480 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(m+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;
t2 = s;
}
if (t1 > t2) {
swap(t1, t2);
swap(d1, d2);
swap(p1, p2);
swap(po1, po2);
swap(n, m);
}
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(), t2-p1[i])-p2.begin()-1;
ll tnow = p1[i]+p2[idx];
int ri = i;
if (tnow <= t1) {
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:58: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]
58 | if (p1[i] > t1) continue;
dishes.cpp:62:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long unsigned int'} and 'int' [-Wsign-compare]
62 | if (tnow <= t1) {
| ~~~~~^~~~~
dishes.cpp:48:5: warning: 't2' may be used uninitialized in this function [-Wmaybe-uninitialized]
48 | if (t1 > t2) {
| ^~
dishes.cpp:48:5: warning: 't1' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
20480 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
20480 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
20480 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |