Submission #421827

# Submission time Handle Problem Language Result Execution time Memory
421827 2021-06-09T12:43:03 Z jamezzz Food Court (JOI21_foodcourt) C++17
7 / 100
1000 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;

#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb emplace_back
typedef long long ll;
typedef pair<int,ll> ii;

#define maxn 250005

int n,m,q,t,l,r,c,ans[maxn];
ll k;
deque<ii> dq[maxn];

int main(){
	sf("%d%d%d",&n,&m,&q);
	for(int i=0;i<q;++i){
		sf("%d",&t);
		if(t==1){
			sf("%d%d%d%lld",&l,&r,&c,&k);
			for(int j=l;j<=r;++j)dq[j].push_back({c,k});
		}
		if(t==2){
			sf("%d%d%lld",&l,&r,&k);
			for(int j=l;j<=r;++j){
				ll rem=k;
				while(!dq[j].empty()){
					if(dq[j].front().se<=rem){
						rem-=dq[j].front().se;
						dq[j].pop_front();
					}
					else{
						dq[j].front().se-=rem;
						rem=0;
					}
					if(rem==0)break;
				}
			}
		}
		if(t==3){
			sf("%d%lld",&l,&k);
			int ans=0;
			for(int i=0;i<dq[l].size();++i){
				if(dq[l][i].se>=k){ ans=dq[l][i].fi;break; }
				else k-=dq[l][i].se;
			}
			pf("%d\n",ans);
		}
	}
	
}

/*
3 5 7
1 2 3 5 2
1 1 2 2 4
3 2 3
2 1 3 3
3 1 2
1 2 3 4 2
3 3 2

3 4 7
1 1 2 1 1
1 1 3 4 1
2 2 3 1
2 1 3 1
1 1 2 2 1
3 1 1
3 3 2

*/

Compilation message

foodcourt.cpp: In function 'int main()':
foodcourt.cpp:46:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |    for(int i=0;i<dq[l].size();++i){
      |                ~^~~~~~~~~~~~~
foodcourt.cpp:19:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  sf("%d%d%d",&n,&m,&q);
      |    ^
foodcourt.cpp:21:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   sf("%d",&t);
      |     ^
foodcourt.cpp:23:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |    sf("%d%d%d%lld",&l,&r,&c,&k);
      |      ^
foodcourt.cpp:27:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |    sf("%d%d%lld",&l,&r,&k);
      |      ^
foodcourt.cpp:44:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |    sf("%d%lld",&l,&k);
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 125 ms 169028 KB Output is correct
2 Correct 141 ms 169376 KB Output is correct
3 Correct 132 ms 176124 KB Output is correct
4 Correct 147 ms 179568 KB Output is correct
5 Correct 119 ms 168572 KB Output is correct
6 Correct 117 ms 168504 KB Output is correct
7 Correct 136 ms 181128 KB Output is correct
8 Correct 142 ms 176732 KB Output is correct
9 Correct 134 ms 169516 KB Output is correct
10 Correct 139 ms 176248 KB Output is correct
11 Correct 137 ms 173372 KB Output is correct
12 Correct 133 ms 169584 KB Output is correct
13 Correct 134 ms 169548 KB Output is correct
14 Correct 139 ms 170648 KB Output is correct
15 Correct 134 ms 171460 KB Output is correct
16 Correct 139 ms 170564 KB Output is correct
17 Correct 128 ms 169004 KB Output is correct
18 Correct 134 ms 169004 KB Output is correct
19 Correct 111 ms 168516 KB Output is correct
20 Correct 115 ms 168516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 125 ms 169028 KB Output is correct
2 Correct 141 ms 169376 KB Output is correct
3 Correct 132 ms 176124 KB Output is correct
4 Correct 147 ms 179568 KB Output is correct
5 Correct 119 ms 168572 KB Output is correct
6 Correct 117 ms 168504 KB Output is correct
7 Correct 136 ms 181128 KB Output is correct
8 Correct 142 ms 176732 KB Output is correct
9 Correct 134 ms 169516 KB Output is correct
10 Correct 139 ms 176248 KB Output is correct
11 Correct 137 ms 173372 KB Output is correct
12 Correct 133 ms 169584 KB Output is correct
13 Correct 134 ms 169548 KB Output is correct
14 Correct 139 ms 170648 KB Output is correct
15 Correct 134 ms 171460 KB Output is correct
16 Correct 139 ms 170564 KB Output is correct
17 Correct 128 ms 169004 KB Output is correct
18 Correct 134 ms 169004 KB Output is correct
19 Correct 111 ms 168516 KB Output is correct
20 Correct 115 ms 168516 KB Output is correct
21 Correct 131 ms 169284 KB Output is correct
22 Correct 150 ms 169576 KB Output is correct
23 Correct 140 ms 175852 KB Output is correct
24 Correct 160 ms 179580 KB Output is correct
25 Correct 125 ms 168552 KB Output is correct
26 Correct 126 ms 168548 KB Output is correct
27 Correct 155 ms 180452 KB Output is correct
28 Correct 149 ms 177580 KB Output is correct
29 Correct 144 ms 171196 KB Output is correct
30 Correct 153 ms 175720 KB Output is correct
31 Correct 163 ms 173100 KB Output is correct
32 Correct 141 ms 169356 KB Output is correct
33 Correct 189 ms 169452 KB Output is correct
34 Correct 174 ms 171568 KB Output is correct
35 Correct 142 ms 170100 KB Output is correct
36 Correct 147 ms 170616 KB Output is correct
37 Correct 126 ms 168472 KB Output is correct
38 Correct 131 ms 168576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 168612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1100 ms 257108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 125 ms 169028 KB Output is correct
2 Correct 141 ms 169376 KB Output is correct
3 Correct 132 ms 176124 KB Output is correct
4 Correct 147 ms 179568 KB Output is correct
5 Correct 119 ms 168572 KB Output is correct
6 Correct 117 ms 168504 KB Output is correct
7 Correct 136 ms 181128 KB Output is correct
8 Correct 142 ms 176732 KB Output is correct
9 Correct 134 ms 169516 KB Output is correct
10 Correct 139 ms 176248 KB Output is correct
11 Correct 137 ms 173372 KB Output is correct
12 Correct 133 ms 169584 KB Output is correct
13 Correct 134 ms 169548 KB Output is correct
14 Correct 139 ms 170648 KB Output is correct
15 Correct 134 ms 171460 KB Output is correct
16 Correct 139 ms 170564 KB Output is correct
17 Correct 128 ms 169004 KB Output is correct
18 Correct 134 ms 169004 KB Output is correct
19 Correct 111 ms 168516 KB Output is correct
20 Correct 115 ms 168516 KB Output is correct
21 Execution timed out 1081 ms 168612 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 634 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 125 ms 169028 KB Output is correct
2 Correct 141 ms 169376 KB Output is correct
3 Correct 132 ms 176124 KB Output is correct
4 Correct 147 ms 179568 KB Output is correct
5 Correct 119 ms 168572 KB Output is correct
6 Correct 117 ms 168504 KB Output is correct
7 Correct 136 ms 181128 KB Output is correct
8 Correct 142 ms 176732 KB Output is correct
9 Correct 134 ms 169516 KB Output is correct
10 Correct 139 ms 176248 KB Output is correct
11 Correct 137 ms 173372 KB Output is correct
12 Correct 133 ms 169584 KB Output is correct
13 Correct 134 ms 169548 KB Output is correct
14 Correct 139 ms 170648 KB Output is correct
15 Correct 134 ms 171460 KB Output is correct
16 Correct 139 ms 170564 KB Output is correct
17 Correct 128 ms 169004 KB Output is correct
18 Correct 134 ms 169004 KB Output is correct
19 Correct 111 ms 168516 KB Output is correct
20 Correct 115 ms 168516 KB Output is correct
21 Correct 131 ms 169284 KB Output is correct
22 Correct 150 ms 169576 KB Output is correct
23 Correct 140 ms 175852 KB Output is correct
24 Correct 160 ms 179580 KB Output is correct
25 Correct 125 ms 168552 KB Output is correct
26 Correct 126 ms 168548 KB Output is correct
27 Correct 155 ms 180452 KB Output is correct
28 Correct 149 ms 177580 KB Output is correct
29 Correct 144 ms 171196 KB Output is correct
30 Correct 153 ms 175720 KB Output is correct
31 Correct 163 ms 173100 KB Output is correct
32 Correct 141 ms 169356 KB Output is correct
33 Correct 189 ms 169452 KB Output is correct
34 Correct 174 ms 171568 KB Output is correct
35 Correct 142 ms 170100 KB Output is correct
36 Correct 147 ms 170616 KB Output is correct
37 Correct 126 ms 168472 KB Output is correct
38 Correct 131 ms 168576 KB Output is correct
39 Execution timed out 1081 ms 168612 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 125 ms 169028 KB Output is correct
2 Correct 141 ms 169376 KB Output is correct
3 Correct 132 ms 176124 KB Output is correct
4 Correct 147 ms 179568 KB Output is correct
5 Correct 119 ms 168572 KB Output is correct
6 Correct 117 ms 168504 KB Output is correct
7 Correct 136 ms 181128 KB Output is correct
8 Correct 142 ms 176732 KB Output is correct
9 Correct 134 ms 169516 KB Output is correct
10 Correct 139 ms 176248 KB Output is correct
11 Correct 137 ms 173372 KB Output is correct
12 Correct 133 ms 169584 KB Output is correct
13 Correct 134 ms 169548 KB Output is correct
14 Correct 139 ms 170648 KB Output is correct
15 Correct 134 ms 171460 KB Output is correct
16 Correct 139 ms 170564 KB Output is correct
17 Correct 128 ms 169004 KB Output is correct
18 Correct 134 ms 169004 KB Output is correct
19 Correct 111 ms 168516 KB Output is correct
20 Correct 115 ms 168516 KB Output is correct
21 Correct 131 ms 169284 KB Output is correct
22 Correct 150 ms 169576 KB Output is correct
23 Correct 140 ms 175852 KB Output is correct
24 Correct 160 ms 179580 KB Output is correct
25 Correct 125 ms 168552 KB Output is correct
26 Correct 126 ms 168548 KB Output is correct
27 Correct 155 ms 180452 KB Output is correct
28 Correct 149 ms 177580 KB Output is correct
29 Correct 144 ms 171196 KB Output is correct
30 Correct 153 ms 175720 KB Output is correct
31 Correct 163 ms 173100 KB Output is correct
32 Correct 141 ms 169356 KB Output is correct
33 Correct 189 ms 169452 KB Output is correct
34 Correct 174 ms 171568 KB Output is correct
35 Correct 142 ms 170100 KB Output is correct
36 Correct 147 ms 170616 KB Output is correct
37 Correct 126 ms 168472 KB Output is correct
38 Correct 131 ms 168576 KB Output is correct
39 Execution timed out 1081 ms 168612 KB Time limit exceeded
40 Halted 0 ms 0 KB -