Submission #122810

# Submission time Handle Problem Language Result Execution time Memory
122810 2019-06-29T10:15:55 Z WhipppedCream Two Dishes (JOI19_dishes) C++17
0 / 100
220 ms 23524 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 1e6+5;

int n, m;
ll a[maxn];
ll b[maxn];
ll p[maxn];
ll q[maxn];
ll s[maxn];
ll t[maxn];

int find_end(ll k)
{
	return upper_bound(b+1, b+m+1, k)-b-1;
}

int main()
{
	scanf("%d %d", &n, &m);
	for(int i = 1; i<= n; i++) scanf("%lld %lld %lld", &a[i], &s[i], &p[i]);
	for(int i = 1; i<= m; i++) scanf("%lld %lld %lld", &b[i], &t[i], &q[i]);
	ll lim = t[1];
	for(int i = 1; i<= m; i++)
	{
		b[i] += b[i-1];
		q[i] += q[i-1];
	}
	ll run = 0;
	ll cum = 0;
	ll best = -1e18;
	best = max(best, q[find_end(lim)]);
	for(int i = 1; i<= n; i++)
	{
		run += a[i];
		cum += p[i];
		best = max(best, cum+q[find_end(lim-run)]);
	}
	printf("%lld\n", best);
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
dishes.cpp:29:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i<= n; i++) scanf("%lld %lld %lld", &a[i], &s[i], &p[i]);
                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:30:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i<= m; i++) scanf("%lld %lld %lld", &b[i], &t[i], &q[i]);
                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 217 ms 23348 KB Output is correct
2 Correct 220 ms 23524 KB Output is correct
3 Correct 212 ms 23036 KB Output is correct
4 Correct 215 ms 23344 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 217 ms 23348 KB Output is correct
2 Correct 220 ms 23524 KB Output is correct
3 Correct 212 ms 23036 KB Output is correct
4 Correct 215 ms 23344 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 217 ms 23348 KB Output is correct
2 Correct 220 ms 23524 KB Output is correct
3 Correct 212 ms 23036 KB Output is correct
4 Correct 215 ms 23344 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -