답안 #283161

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
283161 2020-08-25T10:43:47 Z cgiosy Akvizna (COCI19_akvizna) C++17
컴파일 오류
0 ms 0 KB
#pragma GCC optimize("Ofast")
#include <cstdio>
struct fn {
	double x;
	int j, c;
};
int cr(fn& a, fn& b) { return a.x!=b.x ? fmin((a.j-b.j)/(a.x-b.x), 1e9) : 1e9; }
int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	double l=0, r=1+1e-10;

	int C[N+1];
	fn D[N+1];
	D[0]={};
	while(1) {
		bool last=r-l<1e-10;
		auto m=(l+r)/2;
		int k=0, s=0, e=0;
		C[0]=N;
		for(int i=1; i<=N && (last || k<=K); i++) {
			while(C[s]<i) s++;
			fn t{D[s].x+double(i-D[s].j)/i-m, i, k=D[s].c+1};
			while(s<e && C[e-1]>=(C[e]=cr(D[e], t))) e--;
			if(s==e) C[e]=cr(D[e], t);
			D[++e]=t, C[e]=N;
		}
		if(k==K || last) return!printf("%.9lf", D[e].x+K*m);
		(k>K?l:r)=m;
	}
}

Compilation message

akvizna.cpp: In function 'int cr(fn&, fn&)':
akvizna.cpp:7:42: error: 'fmin' was not declared in this scope; did you mean 'fn'?
    7 | int cr(fn& a, fn& b) { return a.x!=b.x ? fmin((a.j-b.j)/(a.x-b.x), 1e9) : 1e9; }
      |                                          ^~~~
      |                                          fn
akvizna.cpp: In function 'int main()':
akvizna.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf("%d%d", &N, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~