답안 #917430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
917430 2024-01-28T07:51:41 Z PM1 MP3 Player (CEOI10_mp3player) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
const ll mxn=1e5+5,sz=(1<<20);
ll n,vmx,v2,t[mxn],a[mxn];
vector<pair<ll,ll>>v;
struct segment{
	ll mx[sz],mn[sz],lazy[sz];
	void shift(ll id){
		for(ll i=0;i<2;i++){
			mx[id*2+i]+=lazy[id];
			mn[id*2+i]+=lazy[id];
			lazy[id*2+i]+=lazy[id];
		}
		lazy[id]=0;
	}
	void add(ll id,ll L,ll R,ll l,ll r,ll x){
		if(L==l && R==r){
			lazy[id]+=x;
			mx[id]+=x;
			mn[id]+=x;
			return ;
		}
		if(lazy[id])
			shift(id);
		ll mid=(L+R)/2;
		if(l<mid)
			add(id*2,L,mid,l,min(r,mid),x);
		if(r>mid)
			add(id*2+1,mid,R,max(l,mid),r,x);
		mx[id]=max(mx[id*2],mx[id*2+1]);
		mn[id]=min(mn[id*2],mn[id*2+1]);
	}
}seg;
int main(){
	cin>>n>>vmx>>v2;
	for(ll i=1;i<=n;i++){
		char x;
		cin>>x>>t[i];
		if(x=='+')a[i]=1;
		else a[i]=-1;
		if(i!=1)seg.add(1,1,n+2,1,i+1,-a[i]);
	}
	seg.add(1,1,n+2,1,n+2,v2);
	for(ll i=n;i>1;i--){
		t[i]-=t[i-1];
		v.push_back({t[i],i});
	}
	v.push_back({0,0});
	sort(v.begin(),v.end());
	ll p=v.back().fr;
	while(v.size()){//cout<<seg.mx[1]<<" "<<seg.mn[1]<<endl;
		if(seg.mx[1]<=vmx && seg.mn[1]>=0)break;
		while(v.back().fr==p){
			seg.add(1,1,n+2,1,v.back().sc+1,a[v.back().sc]);
			v.pop_back();
		}
		p=v.back().fr;
	}
	cout<<v.back().fr<<" ";
	ll l=0,r=vmx+1,y=v.back().fr;
	while(r-l>1){
		ll mid=(l+r)/2,x=mid;
		for(ll i=2;i<=n;i++){
			if(y>=t[i]){
				x+=a[i];
				x=max(0,x);
				x=min(x,vmx);
			}
		}
		if(x<=v2)l=mid;
		else r=mid;
	}
	cout<<l;
}

Compilation message

mp3player.cpp:5:7: error: 'll' does not name a type
    5 | const ll mxn=1e5+5,sz=(1<<20);
      |       ^~
mp3player.cpp:6:1: error: 'll' does not name a type
    6 | ll n,vmx,v2,t[mxn],a[mxn];
      | ^~
mp3player.cpp:7:13: error: 'll' was not declared in this scope
    7 | vector<pair<ll,ll>>v;
      |             ^~
mp3player.cpp:7:16: error: 'll' was not declared in this scope
    7 | vector<pair<ll,ll>>v;
      |                ^~
mp3player.cpp:7:16: error: template argument 1 is invalid
mp3player.cpp:7:16: error: template argument 2 is invalid
mp3player.cpp:7:18: error: template argument 1 is invalid
    7 | vector<pair<ll,ll>>v;
      |                  ^~
mp3player.cpp:7:18: error: template argument 2 is invalid
mp3player.cpp:9:2: error: 'll' does not name a type
    9 |  ll mx[sz],mn[sz],lazy[sz];
      |  ^~
mp3player.cpp:10:13: error: 'll' has not been declared
   10 |  void shift(ll id){
      |             ^~
mp3player.cpp:18:11: error: 'll' has not been declared
   18 |  void add(ll id,ll L,ll R,ll l,ll r,ll x){
      |           ^~
mp3player.cpp:18:17: error: 'll' has not been declared
   18 |  void add(ll id,ll L,ll R,ll l,ll r,ll x){
      |                 ^~
mp3player.cpp:18:22: error: 'll' has not been declared
   18 |  void add(ll id,ll L,ll R,ll l,ll r,ll x){
      |                      ^~
mp3player.cpp:18:27: error: 'll' has not been declared
   18 |  void add(ll id,ll L,ll R,ll l,ll r,ll x){
      |                           ^~
mp3player.cpp:18:32: error: 'll' has not been declared
   18 |  void add(ll id,ll L,ll R,ll l,ll r,ll x){
      |                                ^~
mp3player.cpp:18:37: error: 'll' has not been declared
   18 |  void add(ll id,ll L,ll R,ll l,ll r,ll x){
      |                                     ^~
mp3player.cpp: In member function 'void segment::shift(int)':
mp3player.cpp:11:7: error: 'll' was not declared in this scope
   11 |   for(ll i=0;i<2;i++){
      |       ^~
mp3player.cpp:11:14: error: 'i' was not declared in this scope
   11 |   for(ll i=0;i<2;i++){
      |              ^
mp3player.cpp:12:4: error: 'mx' was not declared in this scope
   12 |    mx[id*2+i]+=lazy[id];
      |    ^~
mp3player.cpp:12:16: error: 'lazy' was not declared in this scope
   12 |    mx[id*2+i]+=lazy[id];
      |                ^~~~
mp3player.cpp:13:4: error: 'mn' was not declared in this scope; did you mean 'yn'?
   13 |    mn[id*2+i]+=lazy[id];
      |    ^~
      |    yn
mp3player.cpp:16:3: error: 'lazy' was not declared in this scope
   16 |   lazy[id]=0;
      |   ^~~~
mp3player.cpp: In member function 'void segment::add(int, int, int, int, int, int)':
mp3player.cpp:20:4: error: 'lazy' was not declared in this scope
   20 |    lazy[id]+=x;
      |    ^~~~
mp3player.cpp:21:4: error: 'mx' was not declared in this scope; did you mean 'x'?
   21 |    mx[id]+=x;
      |    ^~
      |    x
mp3player.cpp:22:4: error: 'mn' was not declared in this scope; did you mean 'yn'?
   22 |    mn[id]+=x;
      |    ^~
      |    yn
mp3player.cpp:25:6: error: 'lazy' was not declared in this scope
   25 |   if(lazy[id])
      |      ^~~~
mp3player.cpp:27:3: error: 'll' was not declared in this scope; did you mean 'l'?
   27 |   ll mid=(L+R)/2;
      |   ^~
      |   l
mp3player.cpp:28:8: error: 'mid' was not declared in this scope; did you mean 'id'?
   28 |   if(l<mid)
      |        ^~~
      |        id
mp3player.cpp:30:8: error: 'mid' was not declared in this scope; did you mean 'id'?
   30 |   if(r>mid)
      |        ^~~
      |        id
mp3player.cpp:32:3: error: 'mx' was not declared in this scope; did you mean 'x'?
   32 |   mx[id]=max(mx[id*2],mx[id*2+1]);
      |   ^~
      |   x
mp3player.cpp:33:3: error: 'mn' was not declared in this scope; did you mean 'yn'?
   33 |   mn[id]=min(mn[id*2],mn[id*2+1]);
      |   ^~
      |   yn
mp3player.cpp: In function 'int main()':
mp3player.cpp:37:7: error: 'n' was not declared in this scope
   37 |  cin>>n>>vmx>>v2;
      |       ^
mp3player.cpp:37:10: error: 'vmx' was not declared in this scope
   37 |  cin>>n>>vmx>>v2;
      |          ^~~
mp3player.cpp:37:15: error: 'v2' was not declared in this scope; did you mean 'v'?
   37 |  cin>>n>>vmx>>v2;
      |               ^~
      |               v
mp3player.cpp:38:6: error: 'll' was not declared in this scope
   38 |  for(ll i=1;i<=n;i++){
      |      ^~
mp3player.cpp:38:13: error: 'i' was not declared in this scope
   38 |  for(ll i=1;i<=n;i++){
      |             ^
mp3player.cpp:40:11: error: 't' was not declared in this scope
   40 |   cin>>x>>t[i];
      |           ^
mp3player.cpp:41:13: error: 'a' was not declared in this scope
   41 |   if(x=='+')a[i]=1;
      |             ^
mp3player.cpp:42:8: error: 'a' was not declared in this scope
   42 |   else a[i]=-1;
      |        ^
mp3player.cpp:43:34: error: 'a' was not declared in this scope
   43 |   if(i!=1)seg.add(1,1,n+2,1,i+1,-a[i]);
      |                                  ^
mp3player.cpp:46:6: error: 'll' was not declared in this scope
   46 |  for(ll i=n;i>1;i--){
      |      ^~
mp3player.cpp:46:13: error: 'i' was not declared in this scope
   46 |  for(ll i=n;i>1;i--){
      |             ^
mp3player.cpp:47:3: error: 't' was not declared in this scope
   47 |   t[i]-=t[i-1];
      |   ^
mp3player.cpp:48:5: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   48 |   v.push_back({t[i],i});
      |     ^~~~~~~~~
mp3player.cpp:50:4: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   50 |  v.push_back({0,0});
      |    ^~~~~~~~~
mp3player.cpp:51:9: error: request for member 'begin' in 'v', which is of non-class type 'int'
   51 |  sort(v.begin(),v.end());
      |         ^~~~~
mp3player.cpp:51:19: error: request for member 'end' in 'v', which is of non-class type 'int'
   51 |  sort(v.begin(),v.end());
      |                   ^~~
mp3player.cpp:52:2: error: 'll' was not declared in this scope
   52 |  ll p=v.back().fr;
      |  ^~
mp3player.cpp:53:10: error: request for member 'size' in 'v', which is of non-class type 'int'
   53 |  while(v.size()){//cout<<seg.mx[1]<<" "<<seg.mn[1]<<endl;
      |          ^~~~
mp3player.cpp:54:10: error: 'struct segment' has no member named 'mx'
   54 |   if(seg.mx[1]<=vmx && seg.mn[1]>=0)break;
      |          ^~
mp3player.cpp:54:28: error: 'struct segment' has no member named 'mn'
   54 |   if(seg.mx[1]<=vmx && seg.mn[1]>=0)break;
      |                            ^~
mp3player.cpp:55:11: error: request for member 'back' in 'v', which is of non-class type 'int'
   55 |   while(v.back().fr==p){
      |           ^~~~
mp3player.cpp:55:22: error: 'p' was not declared in this scope
   55 |   while(v.back().fr==p){
      |                      ^
mp3player.cpp:56:24: error: request for member 'back' in 'v', which is of non-class type 'int'
   56 |    seg.add(1,1,n+2,1,v.back().sc+1,a[v.back().sc]);
      |                        ^~~~
mp3player.cpp:56:36: error: 'a' was not declared in this scope
   56 |    seg.add(1,1,n+2,1,v.back().sc+1,a[v.back().sc]);
      |                                    ^
mp3player.cpp:56:40: error: request for member 'back' in 'v', which is of non-class type 'int'
   56 |    seg.add(1,1,n+2,1,v.back().sc+1,a[v.back().sc]);
      |                                        ^~~~
mp3player.cpp:57:6: error: request for member 'pop_back' in 'v', which is of non-class type 'int'
   57 |    v.pop_back();
      |      ^~~~~~~~
mp3player.cpp:59:3: error: 'p' was not declared in this scope
   59 |   p=v.back().fr;
      |   ^
mp3player.cpp:59:7: error: request for member 'back' in 'v', which is of non-class type 'int'
   59 |   p=v.back().fr;
      |       ^~~~
mp3player.cpp:61:10: error: request for member 'back' in 'v', which is of non-class type 'int'
   61 |  cout<<v.back().fr<<" ";
      |          ^~~~
mp3player.cpp:62:4: error: expected ';' before 'l'
   62 |  ll l=0,r=vmx+1,y=v.back().fr;
      |    ^~
      |    ;
mp3player.cpp:63:8: error: 'r' was not declared in this scope
   63 |  while(r-l>1){
      |        ^
mp3player.cpp:63:10: error: 'l' was not declared in this scope
   63 |  while(r-l>1){
      |          ^
mp3player.cpp:64:5: error: expected ';' before 'mid'
   64 |   ll mid=(l+r)/2,x=mid;
      |     ^~~~
      |     ;
mp3player.cpp:65:9: error: expected ';' before 'i'
   65 |   for(ll i=2;i<=n;i++){
      |         ^~
      |         ;
mp3player.cpp:65:14: error: 'i' was not declared in this scope
   65 |   for(ll i=2;i<=n;i++){
      |              ^
mp3player.cpp:66:7: error: 'y' was not declared in this scope
   66 |    if(y>=t[i]){
      |       ^
mp3player.cpp:66:10: error: 't' was not declared in this scope
   66 |    if(y>=t[i]){
      |          ^
mp3player.cpp:67:5: error: 'x' was not declared in this scope
   67 |     x+=a[i];
      |     ^
mp3player.cpp:67:8: error: 'a' was not declared in this scope
   67 |     x+=a[i];
      |        ^
mp3player.cpp:72:6: error: 'x' was not declared in this scope
   72 |   if(x<=v2)l=mid;
      |      ^
mp3player.cpp:72:14: error: 'mid' was not declared in this scope
   72 |   if(x<=v2)l=mid;
      |              ^~~
mp3player.cpp:73:10: error: 'mid' was not declared in this scope
   73 |   else r=mid;
      |          ^~~
mp3player.cpp:75:8: error: 'l' was not declared in this scope
   75 |  cout<<l;
      |        ^