답안 #998024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
998024 2024-06-13T08:22:11 Z lovrot Sparklers (JOI17_sparklers) C++17
0 / 100
1 ms 348 KB
#include <cstdio> 
#include <algorithm>
#include <cstring>

using namespace std; 

typedef long long ll;

const int N = 1e5 + 10;
const int OO = 1e9 + 10;

int n, t, k, A[N];

ll B[N];

bool solve(int l, int r, int lo, int hi) { // lo <= l | r <= hi
	int l_ = l, r_ = r;

	for(; lo >= 0 && B[lo] >= B[r]; --lo) {
		if(B[lo] > B[l_]) {
			l_ = lo; 
		}
	}

	for(; hi < n && B[hi] <= B[l]; ++hi) {
		if(B[hi] < B[r_]) { 
			r_ = hi;
		}
	}

	if(lo < 0 && hi >= n) { return 1; }
	if(l == l_ && r == r_) { return 0; }
	return solve(l_, r_, lo, hi); 
}

int main() { 
	scanf("%d%d%d", &n, &k, &t);
	for(int i = 0; i < n; ++i) { scanf("%d", A + i); }

	int lo = -1, hi = OO / t + 1;
	for(int mi = (lo + hi) / 2; hi - lo > 1; mi = (lo + hi) / 2) {
		for(int i = 0; i < n; ++i) {
			B[i] = A[i] - (ll) 2 * mi * t * i;
		}
		if(solve(k - 1, k - 1, k - 1, k - 1)) { hi = mi; }
		else { lo = mi; }
	}

	printf("%d\n", hi);
	return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  scanf("%d%d%d", &n, &k, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:38:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |  for(int i = 0; i < n; ++i) { scanf("%d", A + i); }
      |                               ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -