Submission #421834

#TimeUsernameProblemLanguageResultExecution timeMemory
421834jamezzz푸드 코트 (JOI21_foodcourt)C++17
7 / 100
1100 ms524292 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...