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.024 second
Submitted On: 2025-10-17 00:54:53
#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;
if(st.empty() || st.top() > val)st.push(val);
else{
while(!st.empty() && st.top() < val){
st.pop();
cnt++;
}
st.push(val);
}
}
cout << cnt;
return 0;
}