답안 #537508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
537508 2022-03-15T07:31:59 Z jamezzz Planine (COCI21_planine) C++17
0 / 110
3 ms 724 KB
#include <bits/stdc++.h>
using namespace std;
 
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define INF 102345678923456789
typedef long double ld;
typedef pair<ld,ld> ii;
 
int n,h,x[1000005],y[1000005];
vector<ii> r;
 
int main(){
	sf("%d%d",&n,&h);
	for(int i=1;i<=n;++i)sf("%d%d",&x[i],&y[i]);
	for(int i=3;i<n;i+=2){
		ld m=(ld)(y[i-1]-y[i])/(x[i-1]-x[i]);
		ld c=(ld)y[i]-m*x[i];
		ld x1=(ld)(h-c)/m;
		m=(ld)(y[i+1]-y[i])/(x[i+1]-x[i]);
		c=(ld)y[i]-m*x[i];
		ld x2=(ld)(h-c)/m;
		r.pb({x1,x2});
	}
	sort(all(r),[](ii &a,ii &b){
		if(a.se==b.se)return a.fi<b.fi;
		return a.se<b.se;
	});
	int ans=1;
	ld pv=r[0].se;
	for(int i=0;i<sz(r);++i){
		if(pv<r[i].fi){
			++ans;pv=r[0].se;
		}
	}
	pf("%d\n",ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:19:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  sf("%d%d",&n,&h);
      |    ^
Main.cpp:20:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  for(int i=1;i<=n;++i)sf("%d%d",&x[i],&y[i]);
      |                         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -