Submission #532054

# Submission time Handle Problem Language Result Execution time Memory
532054 2022-03-02T04:31:21 Z 8e7 Two Dishes (JOI19_dishes) C++17
5 / 100
175 ms 27152 KB
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 200005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
struct obj{
	ll t, lim, val;
	obj(){t = lim = val = 0;}
} a[maxn], b[maxn];
ll pref[maxn], v[maxn], pm[maxn];
const ll inf = 1LL<<60;
int main() {
	io
	int n, m;
	cin >> n >> m;
	for (int i = 0;i < n;i++) {
		cin >> a[i].t >> a[i].lim >> a[i].val;	
		if (i) a[i].t += a[i-1].t;
	}
	for (int i = 0;i < m;i++) {
		cin >> b[i].t >> b[i].lim >> b[i].val;
		if (i) b[i].t += b[i-1].t;
		v[i] = b[i].t;
		pref[i] = b[i].val + (i ? pref[i-1] : 0);
	}
	pary(v, v + m);
	ll l = a[0].lim;	
	ll cur = 0, ti = 0, ans = -inf;
	if (v[m-1] > l) {
		int ind = upper_bound(v, v + m, l) - v - 1;
		if (ind >= 0) ans = max(ans, pref[ind]);
	} else if (v[m-1] + a[0].t > l) {
		ans = max(ans, pref[m-1]);	
	}
	for (int i = 0;i < n;i++) {
		ti = a[i].t;	
		cur += a[i].val;
		int ind = upper_bound(v, v + m, l - ti) - v - 1;	
		debug(i, ind, l - ti, cur, pref[ind]);
		if (ind < 0) continue;
		if ((i < n - 1 && a[i+1].t + v[ind] <= l) && (ind < m - 1 && v[ind+1] + ti <= l)) continue;
		ans = max(ans, cur + pref[ind]);
	}
	cout << ans << endl;
		
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:14:19: warning: statement has no effect [-Wunused-value]
   14 | #define pary(...) 0
      |                   ^
dishes.cpp:42:2: note: in expansion of macro 'pary'
   42 |  pary(v, v + m);
      |  ^~~~
dishes.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
dishes.cpp:55:3: note: in expansion of macro 'debug'
   55 |   debug(i, ind, l - ti, cur, pref[ind]);
      |   ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 159 ms 12764 KB Output is correct
2 Correct 175 ms 26616 KB Output is correct
3 Correct 148 ms 26180 KB Output is correct
4 Correct 151 ms 26576 KB Output is correct
5 Correct 4 ms 9676 KB Output is correct
6 Correct 160 ms 26028 KB Output is correct
7 Correct 78 ms 19524 KB Output is correct
8 Correct 74 ms 16592 KB Output is correct
9 Correct 157 ms 27152 KB Output is correct
10 Correct 105 ms 20172 KB Output is correct
11 Correct 104 ms 20692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 9676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 9676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 9676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 9676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 9676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 159 ms 12764 KB Output is correct
2 Correct 175 ms 26616 KB Output is correct
3 Correct 148 ms 26180 KB Output is correct
4 Correct 151 ms 26576 KB Output is correct
5 Correct 4 ms 9676 KB Output is correct
6 Correct 160 ms 26028 KB Output is correct
7 Correct 78 ms 19524 KB Output is correct
8 Correct 74 ms 16592 KB Output is correct
9 Correct 157 ms 27152 KB Output is correct
10 Correct 105 ms 20172 KB Output is correct
11 Correct 104 ms 20692 KB Output is correct
12 Incorrect 4 ms 9676 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 159 ms 12764 KB Output is correct
2 Correct 175 ms 26616 KB Output is correct
3 Correct 148 ms 26180 KB Output is correct
4 Correct 151 ms 26576 KB Output is correct
5 Correct 4 ms 9676 KB Output is correct
6 Correct 160 ms 26028 KB Output is correct
7 Correct 78 ms 19524 KB Output is correct
8 Correct 74 ms 16592 KB Output is correct
9 Correct 157 ms 27152 KB Output is correct
10 Correct 105 ms 20172 KB Output is correct
11 Correct 104 ms 20692 KB Output is correct
12 Incorrect 4 ms 9676 KB Output isn't correct
13 Halted 0 ms 0 KB -