Submission #375828

# Submission time Handle Problem Language Result Execution time Memory
375828 2021-03-10T03:36:22 Z fhvirus Two Dishes (JOI19_dishes) C++17
0 / 100
206 ms 9836 KB
// Knapsack DP is harder than FFT.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
#define ff first
#define ss second
#define pb emplace_back
#define FOR(i,n) for(int i = 0; i < (n); ++i)
#define FOO(i,a,b) for(int i = (a); i <= (b); ++i)
#define AI(x) begin(x),end(x)
template<typename I> bool chmax(I &a, I b){ return a < b ? ( a = b, true ) : false;}
template<typename I> bool chmin(I &a, I b){ return a > b ? ( a = b, true ) : false;}
#ifdef OWO
#define debug(args...) LKJ("[ " + string(#args) + " ]", args)
void LKJ(){cerr<<endl;}
template<class I, class...T> void LKJ(I&&x, T&&...t){ cerr<<x<<", ", LKJ(t...);}
template<class I> void DE(I a, I b){ while(a < b) cerr<<*a<<" \n"[next(a) == b], ++a;}
#else
#define debug(...) 0
#define DE(...) 0
#endif

const int N = 1e6 + 225;
int n, m;
ll a[N], b[N], s[N], t[N], p[N], q[N];

ll dp[N];

int bs(int lft){
	int l = 0, r = m, mid;
	while(l < r){
		mid = (l + r) / 2;
		if(b[mid] <= lft) l = mid + 1;
		else r = mid;
	}
	return l - 1;
}

void solve1(){
	FOO(i,1,n) a[i] += a[i-1];
	FOO(i,1,m) b[i] += b[i-1];
	int ans = 0;
	FOO(i,1,n){
		if(a[i] > s[1]) break;
		int left = s[1] - a[i];
		chmax(ans, i + bs(left));
	}
	cout << ans;
}

int32_t main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> m;
	FOO(i,1,n) cin >> a[i] >> s[i] >> p[i];
	FOO(i,1,m) cin >> b[i] >> t[i] >> q[i];
	solve1();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 206 ms 9836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 206 ms 9836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 206 ms 9836 KB Output isn't correct
2 Halted 0 ms 0 KB -