Submission

Status:

[P][P][P][P][P][PPPPPPPP]

Subtask/Task Score:

{17/17}{17/17}{17/17}{17/17}{17/17}{17/17}

Score: 100

User: dddrrrr

Problemset: ขายรถยนต์

Language: cpp

Time: 0.026 second

Submitted On: 2025-10-17 00:55:40

#include <bits/stdc++.h>
using namespace std;

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cout.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	
	stack <int> st;
	int cnt= 0;
	for(int i=0 ;i<n ;i++){
		int price ,val;
		cin >> price >> val;
		
		while(!st.empty() && st.top() < val){
			st.pop();
			cnt++;
		}
		st.push(val);
		
	}
	
	
	
	cout << cnt;
	
	
	return 0; 
}