Submission #749101

# Submission time Handle Problem Language Result Execution time Memory
749101 2023-05-27T10:12:51 Z TheOpChicken Sparklers (JOI17_sparklers) C++17
0 / 100
1 ms 312 KB
#include <iostream>
using namespace std;

const long long maxN = 1e5 + 5, inf = 1e9;
long long arr[maxN];

int main(){
	long long n, k, t;
	cin >> n >> k >> t;

	k--;

	for (int i = 0; i < n; i++) cin >> arr[i];

	long long l = 1, r = inf, ans = inf;
	while(l <= r){
		long long mid = (l+r)/2, left_margin = inf, right_margin = inf, left_end = 0, right_end = 0;
		for (int i = k-1; i >= 0; i--){
			long long last = arr[k] - (k-i)*2*mid*t;
			if (last < -inf){
				left_end = inf;
				break;
			}

			long long diff = arr[i] - last;
			left_margin = min(left_margin, diff);
			if (i == 0) left_end = diff;
		}

		for (int i = k+1; i < n; i++){
			long long last = arr[k] + (i-k)*2*mid*t;
			if (last > 2*inf){
				right_end = inf;
				break;
			}

			long long diff = last - arr[i];
			right_margin = min(right_margin, diff);
			if (i == n-1) right_end = diff;
		}


		if ((left_margin >= 0 && left_end + right_margin >= 0) || (right_margin >= 0 && right_end + left_margin >= 0)){
			ans = mid;
			r = mid-1;
		}

		else l = mid+1;
	}

	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Incorrect 1 ms 312 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Incorrect 1 ms 312 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Incorrect 1 ms 312 KB Output isn't correct
8 Halted 0 ms 0 KB -