답안 #891380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891380 2023-12-22T20:31:13 Z StefanSebez Sparklers (JOI17_sparklers) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,K,T;scanf("%i%i%i",&n,&K,&T);
    ll x[n+1];for(int i=1;i<=n;i++)scanf("%lld",&x[i]);
    int l=1,r=1e9,res;
    while(l<=r)
	{
		long long mid=(l+r)/2;
		int i=K-1,j=K+1;
		long double t=0,X=x[K],ct=0;
		bool bul=true;
		while(1<=i || j<=n)
		{
			ct++;
			if(1<=i && (X-(x[i]+t*mid))<=2*(ct*T-t)*mid)
			{
				long double t2=t;
				t+=(X-(x[i]+t*mid))/(2*mid);
				X=(X+(x[i]+t2*mid))/2;
				i--;
				continue;
			}
			if(j<=n && ((x[j]-t*mid)-X)<=2*(ct*T-t)*mid)
			{
				long double t2=t;
				t+=((x[j]-t*mid)-X)/(2*mid);
				X=((x[j]-t2*mid)+X)/2;
				j++;
				continue;
			}
			bul=false;
			break;
		}
		if(bul)
		{
			r=mid-1;
			res=mid;
		}
		else l=mid+1;
	}
	printf("%i\n",res);
    return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:6:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     int n,K,T;scanf("%i%i%i",&n,&K,&T);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~
sparklers.cpp:7:41: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     ll x[n+1];for(int i=1;i<=n;i++)scanf("%lld",&x[i]);
      |                                    ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -