Submission #421834

# Submission time Handle Problem Language Result Execution time Memory
421834 2021-06-09T12:48:07 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){
				if(!dq[j].empty()&&dq[j].back().fi==c)dq[j].back().se+=k;
				else 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:49: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]
   49 |    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:30:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |    sf("%d%d%lld",&l,&r,&k);
      |      ^
foodcourt.cpp:47:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |    sf("%d%lld",&l,&k);
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 130 ms 169036 KB Output is correct
2 Correct 144 ms 169392 KB Output is correct
3 Correct 159 ms 175964 KB Output is correct
4 Correct 142 ms 179564 KB Output is correct
5 Correct 131 ms 168476 KB Output is correct
6 Correct 127 ms 168580 KB Output is correct
7 Correct 140 ms 181096 KB Output is correct
8 Correct 153 ms 176692 KB Output is correct
9 Correct 142 ms 169284 KB Output is correct
10 Correct 166 ms 176200 KB Output is correct
11 Correct 163 ms 173308 KB Output is correct
12 Correct 139 ms 169412 KB Output is correct
13 Correct 138 ms 169532 KB Output is correct
14 Correct 142 ms 170620 KB Output is correct
15 Correct 161 ms 171496 KB Output is correct
16 Correct 155 ms 170588 KB Output is correct
17 Correct 150 ms 168940 KB Output is correct
18 Correct 164 ms 169088 KB Output is correct
19 Correct 119 ms 168512 KB Output is correct
20 Correct 113 ms 168532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 169036 KB Output is correct
2 Correct 144 ms 169392 KB Output is correct
3 Correct 159 ms 175964 KB Output is correct
4 Correct 142 ms 179564 KB Output is correct
5 Correct 131 ms 168476 KB Output is correct
6 Correct 127 ms 168580 KB Output is correct
7 Correct 140 ms 181096 KB Output is correct
8 Correct 153 ms 176692 KB Output is correct
9 Correct 142 ms 169284 KB Output is correct
10 Correct 166 ms 176200 KB Output is correct
11 Correct 163 ms 173308 KB Output is correct
12 Correct 139 ms 169412 KB Output is correct
13 Correct 138 ms 169532 KB Output is correct
14 Correct 142 ms 170620 KB Output is correct
15 Correct 161 ms 171496 KB Output is correct
16 Correct 155 ms 170588 KB Output is correct
17 Correct 150 ms 168940 KB Output is correct
18 Correct 164 ms 169088 KB Output is correct
19 Correct 119 ms 168512 KB Output is correct
20 Correct 113 ms 168532 KB Output is correct
21 Correct 147 ms 169300 KB Output is correct
22 Correct 143 ms 169388 KB Output is correct
23 Correct 146 ms 175936 KB Output is correct
24 Correct 163 ms 179612 KB Output is correct
25 Correct 129 ms 168580 KB Output is correct
26 Correct 117 ms 168580 KB Output is correct
27 Correct 152 ms 180604 KB Output is correct
28 Correct 155 ms 177476 KB Output is correct
29 Correct 139 ms 171188 KB Output is correct
30 Correct 144 ms 175792 KB Output is correct
31 Correct 139 ms 173204 KB Output is correct
32 Correct 148 ms 169388 KB Output is correct
33 Correct 125 ms 169448 KB Output is correct
34 Correct 149 ms 171688 KB Output is correct
35 Correct 138 ms 170152 KB Output is correct
36 Correct 148 ms 170564 KB Output is correct
37 Correct 131 ms 168548 KB Output is correct
38 Correct 114 ms 168576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1100 ms 168712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 168528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 130 ms 169036 KB Output is correct
2 Correct 144 ms 169392 KB Output is correct
3 Correct 159 ms 175964 KB Output is correct
4 Correct 142 ms 179564 KB Output is correct
5 Correct 131 ms 168476 KB Output is correct
6 Correct 127 ms 168580 KB Output is correct
7 Correct 140 ms 181096 KB Output is correct
8 Correct 153 ms 176692 KB Output is correct
9 Correct 142 ms 169284 KB Output is correct
10 Correct 166 ms 176200 KB Output is correct
11 Correct 163 ms 173308 KB Output is correct
12 Correct 139 ms 169412 KB Output is correct
13 Correct 138 ms 169532 KB Output is correct
14 Correct 142 ms 170620 KB Output is correct
15 Correct 161 ms 171496 KB Output is correct
16 Correct 155 ms 170588 KB Output is correct
17 Correct 150 ms 168940 KB Output is correct
18 Correct 164 ms 169088 KB Output is correct
19 Correct 119 ms 168512 KB Output is correct
20 Correct 113 ms 168532 KB Output is correct
21 Execution timed out 1100 ms 168712 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 676 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 130 ms 169036 KB Output is correct
2 Correct 144 ms 169392 KB Output is correct
3 Correct 159 ms 175964 KB Output is correct
4 Correct 142 ms 179564 KB Output is correct
5 Correct 131 ms 168476 KB Output is correct
6 Correct 127 ms 168580 KB Output is correct
7 Correct 140 ms 181096 KB Output is correct
8 Correct 153 ms 176692 KB Output is correct
9 Correct 142 ms 169284 KB Output is correct
10 Correct 166 ms 176200 KB Output is correct
11 Correct 163 ms 173308 KB Output is correct
12 Correct 139 ms 169412 KB Output is correct
13 Correct 138 ms 169532 KB Output is correct
14 Correct 142 ms 170620 KB Output is correct
15 Correct 161 ms 171496 KB Output is correct
16 Correct 155 ms 170588 KB Output is correct
17 Correct 150 ms 168940 KB Output is correct
18 Correct 164 ms 169088 KB Output is correct
19 Correct 119 ms 168512 KB Output is correct
20 Correct 113 ms 168532 KB Output is correct
21 Correct 147 ms 169300 KB Output is correct
22 Correct 143 ms 169388 KB Output is correct
23 Correct 146 ms 175936 KB Output is correct
24 Correct 163 ms 179612 KB Output is correct
25 Correct 129 ms 168580 KB Output is correct
26 Correct 117 ms 168580 KB Output is correct
27 Correct 152 ms 180604 KB Output is correct
28 Correct 155 ms 177476 KB Output is correct
29 Correct 139 ms 171188 KB Output is correct
30 Correct 144 ms 175792 KB Output is correct
31 Correct 139 ms 173204 KB Output is correct
32 Correct 148 ms 169388 KB Output is correct
33 Correct 125 ms 169448 KB Output is correct
34 Correct 149 ms 171688 KB Output is correct
35 Correct 138 ms 170152 KB Output is correct
36 Correct 148 ms 170564 KB Output is correct
37 Correct 131 ms 168548 KB Output is correct
38 Correct 114 ms 168576 KB Output is correct
39 Execution timed out 1100 ms 168712 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 130 ms 169036 KB Output is correct
2 Correct 144 ms 169392 KB Output is correct
3 Correct 159 ms 175964 KB Output is correct
4 Correct 142 ms 179564 KB Output is correct
5 Correct 131 ms 168476 KB Output is correct
6 Correct 127 ms 168580 KB Output is correct
7 Correct 140 ms 181096 KB Output is correct
8 Correct 153 ms 176692 KB Output is correct
9 Correct 142 ms 169284 KB Output is correct
10 Correct 166 ms 176200 KB Output is correct
11 Correct 163 ms 173308 KB Output is correct
12 Correct 139 ms 169412 KB Output is correct
13 Correct 138 ms 169532 KB Output is correct
14 Correct 142 ms 170620 KB Output is correct
15 Correct 161 ms 171496 KB Output is correct
16 Correct 155 ms 170588 KB Output is correct
17 Correct 150 ms 168940 KB Output is correct
18 Correct 164 ms 169088 KB Output is correct
19 Correct 119 ms 168512 KB Output is correct
20 Correct 113 ms 168532 KB Output is correct
21 Correct 147 ms 169300 KB Output is correct
22 Correct 143 ms 169388 KB Output is correct
23 Correct 146 ms 175936 KB Output is correct
24 Correct 163 ms 179612 KB Output is correct
25 Correct 129 ms 168580 KB Output is correct
26 Correct 117 ms 168580 KB Output is correct
27 Correct 152 ms 180604 KB Output is correct
28 Correct 155 ms 177476 KB Output is correct
29 Correct 139 ms 171188 KB Output is correct
30 Correct 144 ms 175792 KB Output is correct
31 Correct 139 ms 173204 KB Output is correct
32 Correct 148 ms 169388 KB Output is correct
33 Correct 125 ms 169448 KB Output is correct
34 Correct 149 ms 171688 KB Output is correct
35 Correct 138 ms 170152 KB Output is correct
36 Correct 148 ms 170564 KB Output is correct
37 Correct 131 ms 168548 KB Output is correct
38 Correct 114 ms 168576 KB Output is correct
39 Execution timed out 1100 ms 168712 KB Time limit exceeded
40 Halted 0 ms 0 KB -