답안 #110019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110019 2019-05-08T21:32:47 Z tincamatei Two Dishes (JOI19_dishes) C++14
10 / 100
10000 ms 48652 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1000000;

struct StepSet {
	int n;
	int len[1+MAX_N], art[1+MAX_N];
	long long limit[1+MAX_N];
	long long sp[1+MAX_N];

	int segLen[1+MAX_N];
} meal[2];

int binsrc(int p, long long t) {
	int st = -1, dr = meal[p].n + 1;

	while(dr - st > 1) {
		int mid = (st + dr) / 2;
		if(meal[p].sp[mid] <= t)
			st = mid;
		else
			dr = mid;
	}
	return dr;
}

struct BadSegtree {
	int n;
	long long dp[1+MAX_N];
	int transition[1+MAX_N];

	void addRange(int l, int r, int val) {
		for(int i = l; i <= r; ++i)
			dp[i] += val;
	}

	void modifyTransition(int poz, int val) {
		transition[poz] = val;
	}

	void pushDp() {
		for(int i = 1; i <= n; i++)
			dp[i] = max(dp[i], dp[i - 1] + transition[i]);
	}
} sol;

vector<int> horizontalMod[1+MAX_N+1];

int main() {
#ifdef HOME
	FILE *fin = fopen("input.in", "r");
	FILE *fout = fopen("output.out", "w");
#else
	FILE *fin = stdin;
	FILE *fout = stdout;
#endif

	fscanf(fin, "%d%d", &meal[0].n, &meal[1].n);

	for(int p = 0; p < 2; ++p)
		for(int i = 1; i <= meal[p].n; ++i) {
			fscanf(fin, "%d%lld%d", &meal[p].len[i], &meal[p].limit[i], &meal[p].art[i]);
			meal[p].sp[i] = meal[p].sp[i - 1] + meal[p].len[i];
		}
	
	for(int p = 0; p < 2; ++p)
		for(int i = 1; i <= meal[p].n; ++i)
			meal[p].segLen[i] = binsrc(1 - p, meal[p].limit[i] - meal[p].sp[i]);
	
	sol.n = meal[0].n;
	sol.dp[0] = 0;
	for(int i = 1; i <= meal[0].n; ++i)
		if(meal[0].segLen[i] > 0) {
			sol.dp[i] = sol.dp[i - 1] + meal[0].art[i];
			sol.transition[i] = meal[0].art[i];
			horizontalMod[meal[0].segLen[i]].push_back(i);
		} else
			sol.dp[i] = sol.dp[i - 1];

	for(int i = 1; i <= meal[1].n; ++i) {
		sol.addRange(0, meal[1].segLen[i] - 1, meal[1].art[i]);
		for(auto it: horizontalMod[i])
			sol.modifyTransition(it, 0);
		sol.pushDp();
	}

	fprintf(fout, "%lld", sol.dp[meal[0].n]);
	fclose(fin);
	fclose(fout);
	return 0;
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:60:8: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fscanf(fin, "%d%d", &meal[0].n, &meal[1].n);
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:64:10: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    fscanf(fin, "%d%lld%d", &meal[p].len[i], &meal[p].limit[i], &meal[p].art[i]);
    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10049 ms 40952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 23928 KB Output is correct
2 Correct 21 ms 23936 KB Output is correct
3 Correct 23 ms 23936 KB Output is correct
4 Correct 23 ms 23936 KB Output is correct
5 Correct 23 ms 23936 KB Output is correct
6 Correct 23 ms 23928 KB Output is correct
7 Correct 23 ms 23936 KB Output is correct
8 Correct 22 ms 23936 KB Output is correct
9 Correct 23 ms 23936 KB Output is correct
10 Correct 23 ms 23936 KB Output is correct
11 Correct 24 ms 23936 KB Output is correct
12 Correct 24 ms 23920 KB Output is correct
13 Correct 25 ms 23936 KB Output is correct
14 Correct 26 ms 23936 KB Output is correct
15 Correct 24 ms 23928 KB Output is correct
16 Correct 25 ms 23928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 23928 KB Output is correct
2 Correct 21 ms 23936 KB Output is correct
3 Correct 23 ms 23936 KB Output is correct
4 Correct 23 ms 23936 KB Output is correct
5 Correct 23 ms 23936 KB Output is correct
6 Correct 23 ms 23928 KB Output is correct
7 Correct 23 ms 23936 KB Output is correct
8 Correct 22 ms 23936 KB Output is correct
9 Correct 23 ms 23936 KB Output is correct
10 Correct 23 ms 23936 KB Output is correct
11 Correct 24 ms 23936 KB Output is correct
12 Correct 24 ms 23920 KB Output is correct
13 Correct 25 ms 23936 KB Output is correct
14 Correct 26 ms 23936 KB Output is correct
15 Correct 24 ms 23928 KB Output is correct
16 Correct 25 ms 23928 KB Output is correct
17 Correct 43 ms 24176 KB Output is correct
18 Correct 39 ms 24056 KB Output is correct
19 Correct 42 ms 24184 KB Output is correct
20 Correct 39 ms 24184 KB Output is correct
21 Correct 42 ms 24064 KB Output is correct
22 Correct 43 ms 24064 KB Output is correct
23 Correct 39 ms 24064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 23928 KB Output is correct
2 Correct 21 ms 23936 KB Output is correct
3 Correct 23 ms 23936 KB Output is correct
4 Correct 23 ms 23936 KB Output is correct
5 Correct 23 ms 23936 KB Output is correct
6 Correct 23 ms 23928 KB Output is correct
7 Correct 23 ms 23936 KB Output is correct
8 Correct 22 ms 23936 KB Output is correct
9 Correct 23 ms 23936 KB Output is correct
10 Correct 23 ms 23936 KB Output is correct
11 Correct 24 ms 23936 KB Output is correct
12 Correct 24 ms 23920 KB Output is correct
13 Correct 25 ms 23936 KB Output is correct
14 Correct 26 ms 23936 KB Output is correct
15 Correct 24 ms 23928 KB Output is correct
16 Correct 25 ms 23928 KB Output is correct
17 Correct 43 ms 24176 KB Output is correct
18 Correct 39 ms 24056 KB Output is correct
19 Correct 42 ms 24184 KB Output is correct
20 Correct 39 ms 24184 KB Output is correct
21 Correct 42 ms 24064 KB Output is correct
22 Correct 43 ms 24064 KB Output is correct
23 Correct 39 ms 24064 KB Output is correct
24 Execution timed out 10063 ms 48652 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 23928 KB Output is correct
2 Correct 21 ms 23936 KB Output is correct
3 Correct 23 ms 23936 KB Output is correct
4 Correct 23 ms 23936 KB Output is correct
5 Correct 23 ms 23936 KB Output is correct
6 Correct 23 ms 23928 KB Output is correct
7 Correct 23 ms 23936 KB Output is correct
8 Correct 22 ms 23936 KB Output is correct
9 Correct 23 ms 23936 KB Output is correct
10 Correct 23 ms 23936 KB Output is correct
11 Correct 24 ms 23936 KB Output is correct
12 Correct 24 ms 23920 KB Output is correct
13 Correct 25 ms 23936 KB Output is correct
14 Correct 26 ms 23936 KB Output is correct
15 Correct 24 ms 23928 KB Output is correct
16 Correct 25 ms 23928 KB Output is correct
17 Correct 43 ms 24176 KB Output is correct
18 Correct 39 ms 24056 KB Output is correct
19 Correct 42 ms 24184 KB Output is correct
20 Correct 39 ms 24184 KB Output is correct
21 Correct 42 ms 24064 KB Output is correct
22 Correct 43 ms 24064 KB Output is correct
23 Correct 39 ms 24064 KB Output is correct
24 Execution timed out 10063 ms 48652 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 23928 KB Output is correct
2 Correct 21 ms 23936 KB Output is correct
3 Correct 23 ms 23936 KB Output is correct
4 Correct 23 ms 23936 KB Output is correct
5 Correct 23 ms 23936 KB Output is correct
6 Correct 23 ms 23928 KB Output is correct
7 Correct 23 ms 23936 KB Output is correct
8 Correct 22 ms 23936 KB Output is correct
9 Correct 23 ms 23936 KB Output is correct
10 Correct 23 ms 23936 KB Output is correct
11 Correct 24 ms 23936 KB Output is correct
12 Correct 24 ms 23920 KB Output is correct
13 Correct 25 ms 23936 KB Output is correct
14 Correct 26 ms 23936 KB Output is correct
15 Correct 24 ms 23928 KB Output is correct
16 Correct 25 ms 23928 KB Output is correct
17 Correct 43 ms 24176 KB Output is correct
18 Correct 39 ms 24056 KB Output is correct
19 Correct 42 ms 24184 KB Output is correct
20 Correct 39 ms 24184 KB Output is correct
21 Correct 42 ms 24064 KB Output is correct
22 Correct 43 ms 24064 KB Output is correct
23 Correct 39 ms 24064 KB Output is correct
24 Execution timed out 10063 ms 48652 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10049 ms 40952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10049 ms 40952 KB Time limit exceeded
2 Halted 0 ms 0 KB -