4 solutions

  • 0
    @ 2022-3-24 17:54:01

    水题

    #include<bits/stdc++.h>
    using namespace std;
    int path[100000];
    int t,num,car,i;
    void search(int []){
    	int ans=0;
    	for(int j=0;j<i;j++)
    	{
    		if(path[j] > ans)
    			ans = path[j];	
    	}
    	if(ans == 0)
    		cout<<-1<<endl;
    	else
    		cout<<ans<<endl;
    }
    int main() {
    	std::ios::sync_with_stdio(false);
    	cin>>t;
    	while(t--){
    		stack<int> cnt;
    		cin>>num;
    		if(num == 1){
    			cin>>car;
    			path[i++] = car;
    			cnt.push(car);
    		}
    		else if(num == 2){
    			cnt.pop();
    			i--;
    			path[i]=0;
    		}
    		else
    			search(path);
    	}
        return 0; 
    }
    

    Information

    ID
    1528
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    73
    Accepted
    23
    Uploaded By