P9110
Mason123456 · · 题解
P9110
题面解释
有
思路
开桶。
因为出发时间不同,需要在放进桶时
CODE
注意:为防止
#include <bits/stdc++.h>
using namespace std;
const int N = 3e7 + 10;
const int M = 1e6 + 5;
int x[N], y[N];
int main(){
int n;
cin>>n;
for(int i = 1;i <= n;i++){
int r, w, t;
cin>>r>>w>>t;
if(r == 1){// 向上
y[w - t + M] ++;
}
else{// 向右
x[w - t + M] ++;
}
}
int ans = 0;
for(int i = 0;i <= N;i++){
if(x[i] && y[i]){
ans += min(x[i], y[i]);
}
}
cout<<ans;
}