求hack
查看原帖
求hack
370648
柠檬布丁吖楼主2023/1/28 21:11

一个无脑的做法。这么想的,先算出来需要多久才能看到,然后按离FJ的远近依次判断,如果当前的(top)比下一个要晚看见那么ans++;

只过了样例和题解第二篇(第三篇?)提出的数据。

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<bits/stdc++.h>
#define int long long
using namespace std;

inline int read() {
	int ret=0,f=1;
	char c=getchar();
	for(; c<'0'||c>'9'; c=getchar()) if(c=='-') f=-f;
	for(; c>='0'&&c<='9'; c=getchar()) ret=ret*10+c-'0';
	return ret*f;
}

int n;
const int maxn=5e5+55;
struct cow {
	int t;
	bool operator == (const cow &n1) const {
		return t == n1.t;
	}
	bool operator<(const cow m)const {
		return t<m.t;
	}
} c[maxn],a[maxn];
int _time=0,l[maxn];
bool f[maxn];

bool cmp(cow x,cow y) {
	return x.t<y.t;
}

signed main(void) {

	n=read();

	for(int i=1; i<=n; i++) {
		int x,y,r;
		x=read();
		y=read();
		r=read();
		c[i].t=r*(-x);
	}
                      
	int top=1,o=top+1;
	f[top]=true;
	while(top<=n) {
		if(c[o].t>=c[top].t) {
			f[o]=true;
			top++;
			if(o==top) {
				o++;
			}
		} else {
			top++;
			if(top==o) {
				o++;
			}
		}
	}
	
	int ans=0;
	for(int i=1;i<=n;i++){
		if(f[i]==true){
			ans++;
		}
	}
	
	cout<<ans<<endl;

	return 0;
}
2023/1/28 21:11
加载中...