P1165这代码怎么完全通过不了?
查看原帖
P1165这代码怎么完全通过不了?
1256653
Lily_LB楼主2024/1/16 20:37
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;

int main(){
    long long N,max;
    long long x,y;
    stack<long long>SOS={};
    stack<long long>BOB={};
    stack<long long>C={};
    cout<<"Please input the value of 'N'"<<endl;
    cin>>N;
    for(long long i=0;i<N;i++){
        cin>>x;
        if(x==0){
            cin>>y;
            SOS.push(y);
            }
        if(x==1){
            if(!SOS.empty()){
                SOS.pop();
                }
            }  
        if(x==2){
            max=0;
            while(!BOB.empty()){BOB.pop();}
            while(!SOS.empty()){
                BOB.push(SOS.top());
                SOS.pop();
                if(BOB.top()>max){max=BOB.top();}
                }
            C.push(max);
            //cout<<max<<endl;
            while(!BOB.empty()){
                SOS.push(BOB.top());
                BOB.pop();
                }
            }
        }
    while(!BOB.empty()){BOB.pop();}
    while(!C.empty()){
        BOB.push(C.top());
        C.pop();
        }
    while(!BOB.empty()){cout<<BOB.top()<<endl;BOB.pop();}
    
    return 0;
}
2024/1/16 20:37
加载中...