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: PitsineeN
Problemset: ขายรถยนต์
Language: cpp
Time: 0.100 second
Submitted On: 2026-07-20 15:13:33
//https://grader.gchan.moe/problemset/ku01_65f2_cars
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
bool cmp(const pair<int,int>& a,const pair<int,int>& b){
if(a.second!=b.second) return a.second>b.second;
else a.first < b.first;
}
int main(){
int n;
cin>>n;
vector<pair<int,int>>car;
while(n--){
int p,v;
cin>>p>>v;
car.push_back({p,v});
}
sort(car.begin(),car.end(),cmp);
int min=2e9;
int ans=0;
for(auto temp1:car){
if(temp1.first>min) {
ans++;
}
else min=temp1.first;
}
cout<<ans;
}
// 4
// ราคา efc
// 100 200
// 90 40 x
// 50 41
// 10 30
// ราคา
// 10 30 /
// 50 41>30 /
// 90 40<41 x
// 100 200>41 /
// efc ราคา
// 200 100 < Max /
// 200 101 > 100 x
// 41 50 < 100 /
// 40 90 > 50 x
// 30 10 < 50 /
// 10. 30 /
// 90. 40 x
// 50 41 /
// 100. 200 /
// ราคาแพง ปสภน้อย
// ปสภน้อย ราคาแพง