Submission #722436

# Submission time Handle Problem Language Result Execution time Memory
722436 2023-04-12T00:50:52 Z Abrar_Al_Samit Food Court (JOI21_foodcourt) C++17
14 / 100
1000 ms 411004 KB
#include<bits/stdc++.h>
using namespace std;

const int nax = 65003;
int n, m, q;

vector<pair<long long, int>>lines[nax];


struct BIT {
	long long bit[nax];
	void update(int i, long long val) {
		while(i<nax) {
			bit[i] += val;
			i += i&-i;
		}
	}
	void update(int l, int r, long long val) {
		update(l, val);
		update(r+1, -val);
	}
	long long query(int i) {
		long long ret = 0;
		while(i>0) {
			ret += bit[i];
			i -= i&-i;
		}
		return ret;
	}
} T;

long long fix(int i) {
	long long rem = T.query(i);
	if(lines[i].back().first<rem) {
		T.update(i, i, lines[i].back().first-rem);
		rem = lines[i].back().first;
	}
	return rem;
}
void PlayGround() {
	cin>>n>>m>>q;

	for(int i=1; i<=n; ++i) {
		lines[i].emplace_back(0LL, 0);
	}
	while(q--) {
		int tp;
		cin>>tp;
		if(tp==1) {
			long long l, r, c, k;
			cin>>l>>r>>c>>k;

			for(int i=l; i<=r; ++i) {
				fix(i);
				lines[i].emplace_back(lines[i].back().first+k, c);
			}
		} else if(tp==2) {
			long long l, r, k;
			cin>>l>>r>>k;
			T.update(l, r, k);
		} else {
			long long a, b;
			cin>>a>>b;
			long long rem = fix(a);
			b += rem;
			if(b > lines[a].back().first) {
				cout<<"0\n";
			} else {
				auto it = lower_bound(lines[a].begin(), lines[a].end(), make_pair(b, -1));
				cout<<it->second<<'\n';
			}
		}
	}


	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	PlayGround();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7636 KB Output is correct
2 Correct 13 ms 13252 KB Output is correct
3 Correct 19 ms 15208 KB Output is correct
4 Correct 25 ms 25812 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 25 ms 19148 KB Output is correct
8 Correct 23 ms 19028 KB Output is correct
9 Correct 19 ms 18840 KB Output is correct
10 Correct 23 ms 19924 KB Output is correct
11 Correct 21 ms 20436 KB Output is correct
12 Correct 20 ms 19284 KB Output is correct
13 Correct 28 ms 27732 KB Output is correct
14 Correct 33 ms 32740 KB Output is correct
15 Correct 19 ms 17364 KB Output is correct
16 Correct 39 ms 32288 KB Output is correct
17 Correct 12 ms 10964 KB Output is correct
18 Correct 18 ms 15700 KB Output is correct
19 Correct 3 ms 2132 KB Output is correct
20 Correct 3 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7636 KB Output is correct
2 Correct 13 ms 13252 KB Output is correct
3 Correct 19 ms 15208 KB Output is correct
4 Correct 25 ms 25812 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 25 ms 19148 KB Output is correct
8 Correct 23 ms 19028 KB Output is correct
9 Correct 19 ms 18840 KB Output is correct
10 Correct 23 ms 19924 KB Output is correct
11 Correct 21 ms 20436 KB Output is correct
12 Correct 20 ms 19284 KB Output is correct
13 Correct 28 ms 27732 KB Output is correct
14 Correct 33 ms 32740 KB Output is correct
15 Correct 19 ms 17364 KB Output is correct
16 Correct 39 ms 32288 KB Output is correct
17 Correct 12 ms 10964 KB Output is correct
18 Correct 18 ms 15700 KB Output is correct
19 Correct 3 ms 2132 KB Output is correct
20 Correct 3 ms 2132 KB Output is correct
21 Correct 12 ms 12244 KB Output is correct
22 Correct 13 ms 13396 KB Output is correct
23 Correct 17 ms 17472 KB Output is correct
24 Correct 26 ms 25916 KB Output is correct
25 Correct 2 ms 1876 KB Output is correct
26 Correct 2 ms 1876 KB Output is correct
27 Correct 18 ms 16724 KB Output is correct
28 Correct 19 ms 19796 KB Output is correct
29 Correct 19 ms 19556 KB Output is correct
30 Correct 25 ms 19156 KB Output is correct
31 Correct 18 ms 16096 KB Output is correct
32 Correct 19 ms 16084 KB Output is correct
33 Correct 29 ms 26128 KB Output is correct
34 Correct 34 ms 32620 KB Output is correct
35 Correct 28 ms 24448 KB Output is correct
36 Correct 33 ms 32204 KB Output is correct
37 Correct 2 ms 2004 KB Output is correct
38 Correct 3 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 8468 KB Output is correct
2 Correct 57 ms 10324 KB Output is correct
3 Correct 63 ms 11336 KB Output is correct
4 Correct 60 ms 11264 KB Output is correct
5 Correct 71 ms 14336 KB Output is correct
6 Correct 74 ms 14296 KB Output is correct
7 Correct 18 ms 3280 KB Output is correct
8 Correct 19 ms 3516 KB Output is correct
9 Correct 43 ms 9056 KB Output is correct
10 Correct 52 ms 9036 KB Output is correct
11 Correct 53 ms 9036 KB Output is correct
12 Correct 57 ms 9016 KB Output is correct
13 Correct 52 ms 9924 KB Output is correct
14 Correct 64 ms 11452 KB Output is correct
15 Correct 63 ms 13548 KB Output is correct
16 Correct 68 ms 14184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 7612 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7636 KB Output is correct
2 Correct 13 ms 13252 KB Output is correct
3 Correct 19 ms 15208 KB Output is correct
4 Correct 25 ms 25812 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 25 ms 19148 KB Output is correct
8 Correct 23 ms 19028 KB Output is correct
9 Correct 19 ms 18840 KB Output is correct
10 Correct 23 ms 19924 KB Output is correct
11 Correct 21 ms 20436 KB Output is correct
12 Correct 20 ms 19284 KB Output is correct
13 Correct 28 ms 27732 KB Output is correct
14 Correct 33 ms 32740 KB Output is correct
15 Correct 19 ms 17364 KB Output is correct
16 Correct 39 ms 32288 KB Output is correct
17 Correct 12 ms 10964 KB Output is correct
18 Correct 18 ms 15700 KB Output is correct
19 Correct 3 ms 2132 KB Output is correct
20 Correct 3 ms 2132 KB Output is correct
21 Correct 48 ms 8468 KB Output is correct
22 Correct 57 ms 10324 KB Output is correct
23 Correct 63 ms 11336 KB Output is correct
24 Correct 60 ms 11264 KB Output is correct
25 Correct 71 ms 14336 KB Output is correct
26 Correct 74 ms 14296 KB Output is correct
27 Correct 18 ms 3280 KB Output is correct
28 Correct 19 ms 3516 KB Output is correct
29 Correct 43 ms 9056 KB Output is correct
30 Correct 52 ms 9036 KB Output is correct
31 Correct 53 ms 9036 KB Output is correct
32 Correct 57 ms 9016 KB Output is correct
33 Correct 52 ms 9924 KB Output is correct
34 Correct 64 ms 11452 KB Output is correct
35 Correct 63 ms 13548 KB Output is correct
36 Correct 68 ms 14184 KB Output is correct
37 Execution timed out 1089 ms 391812 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 411004 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7636 KB Output is correct
2 Correct 13 ms 13252 KB Output is correct
3 Correct 19 ms 15208 KB Output is correct
4 Correct 25 ms 25812 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 25 ms 19148 KB Output is correct
8 Correct 23 ms 19028 KB Output is correct
9 Correct 19 ms 18840 KB Output is correct
10 Correct 23 ms 19924 KB Output is correct
11 Correct 21 ms 20436 KB Output is correct
12 Correct 20 ms 19284 KB Output is correct
13 Correct 28 ms 27732 KB Output is correct
14 Correct 33 ms 32740 KB Output is correct
15 Correct 19 ms 17364 KB Output is correct
16 Correct 39 ms 32288 KB Output is correct
17 Correct 12 ms 10964 KB Output is correct
18 Correct 18 ms 15700 KB Output is correct
19 Correct 3 ms 2132 KB Output is correct
20 Correct 3 ms 2132 KB Output is correct
21 Correct 12 ms 12244 KB Output is correct
22 Correct 13 ms 13396 KB Output is correct
23 Correct 17 ms 17472 KB Output is correct
24 Correct 26 ms 25916 KB Output is correct
25 Correct 2 ms 1876 KB Output is correct
26 Correct 2 ms 1876 KB Output is correct
27 Correct 18 ms 16724 KB Output is correct
28 Correct 19 ms 19796 KB Output is correct
29 Correct 19 ms 19556 KB Output is correct
30 Correct 25 ms 19156 KB Output is correct
31 Correct 18 ms 16096 KB Output is correct
32 Correct 19 ms 16084 KB Output is correct
33 Correct 29 ms 26128 KB Output is correct
34 Correct 34 ms 32620 KB Output is correct
35 Correct 28 ms 24448 KB Output is correct
36 Correct 33 ms 32204 KB Output is correct
37 Correct 2 ms 2004 KB Output is correct
38 Correct 3 ms 2132 KB Output is correct
39 Correct 48 ms 8468 KB Output is correct
40 Correct 57 ms 10324 KB Output is correct
41 Correct 63 ms 11336 KB Output is correct
42 Correct 60 ms 11264 KB Output is correct
43 Correct 71 ms 14336 KB Output is correct
44 Correct 74 ms 14296 KB Output is correct
45 Correct 18 ms 3280 KB Output is correct
46 Correct 19 ms 3516 KB Output is correct
47 Correct 43 ms 9056 KB Output is correct
48 Correct 52 ms 9036 KB Output is correct
49 Correct 53 ms 9036 KB Output is correct
50 Correct 57 ms 9016 KB Output is correct
51 Correct 52 ms 9924 KB Output is correct
52 Correct 64 ms 11452 KB Output is correct
53 Correct 63 ms 13548 KB Output is correct
54 Correct 68 ms 14184 KB Output is correct
55 Execution timed out 1089 ms 391812 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7636 KB Output is correct
2 Correct 13 ms 13252 KB Output is correct
3 Correct 19 ms 15208 KB Output is correct
4 Correct 25 ms 25812 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 25 ms 19148 KB Output is correct
8 Correct 23 ms 19028 KB Output is correct
9 Correct 19 ms 18840 KB Output is correct
10 Correct 23 ms 19924 KB Output is correct
11 Correct 21 ms 20436 KB Output is correct
12 Correct 20 ms 19284 KB Output is correct
13 Correct 28 ms 27732 KB Output is correct
14 Correct 33 ms 32740 KB Output is correct
15 Correct 19 ms 17364 KB Output is correct
16 Correct 39 ms 32288 KB Output is correct
17 Correct 12 ms 10964 KB Output is correct
18 Correct 18 ms 15700 KB Output is correct
19 Correct 3 ms 2132 KB Output is correct
20 Correct 3 ms 2132 KB Output is correct
21 Correct 12 ms 12244 KB Output is correct
22 Correct 13 ms 13396 KB Output is correct
23 Correct 17 ms 17472 KB Output is correct
24 Correct 26 ms 25916 KB Output is correct
25 Correct 2 ms 1876 KB Output is correct
26 Correct 2 ms 1876 KB Output is correct
27 Correct 18 ms 16724 KB Output is correct
28 Correct 19 ms 19796 KB Output is correct
29 Correct 19 ms 19556 KB Output is correct
30 Correct 25 ms 19156 KB Output is correct
31 Correct 18 ms 16096 KB Output is correct
32 Correct 19 ms 16084 KB Output is correct
33 Correct 29 ms 26128 KB Output is correct
34 Correct 34 ms 32620 KB Output is correct
35 Correct 28 ms 24448 KB Output is correct
36 Correct 33 ms 32204 KB Output is correct
37 Correct 2 ms 2004 KB Output is correct
38 Correct 3 ms 2132 KB Output is correct
39 Correct 48 ms 8468 KB Output is correct
40 Correct 57 ms 10324 KB Output is correct
41 Correct 63 ms 11336 KB Output is correct
42 Correct 60 ms 11264 KB Output is correct
43 Correct 71 ms 14336 KB Output is correct
44 Correct 74 ms 14296 KB Output is correct
45 Correct 18 ms 3280 KB Output is correct
46 Correct 19 ms 3516 KB Output is correct
47 Correct 43 ms 9056 KB Output is correct
48 Correct 52 ms 9036 KB Output is correct
49 Correct 53 ms 9036 KB Output is correct
50 Correct 57 ms 9016 KB Output is correct
51 Correct 52 ms 9924 KB Output is correct
52 Correct 64 ms 11452 KB Output is correct
53 Correct 63 ms 13548 KB Output is correct
54 Correct 68 ms 14184 KB Output is correct
55 Runtime error 9 ms 7612 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -