답안 #997764

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
997764 2024-06-12T19:22:52 Z lovrot Sparklers (JOI17_sparklers) C++17
0 / 100
4 ms 4188 KB
#include <cstdio> 
#include <algorithm>
#include <cstring>

using namespace std; 

typedef long long ll;

const int N = 1010;
const int OO = 2e9 + 10;

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

int dp[N][N];

bool solve(int l, int r, int s) {
	if(l < 0 || r >= n || X[r] - X[l] > (ll) (r - l) * t * 2 * s) { return 0; } 
	if(dp[l][r] != -1) { return 1; }

	return dp[l][r] = solve(l - 1, r, s) | solve(l, r + 1, s);
}

int main() { 
	scanf("%d%d%d", &n, &k, &t);
	for(int i = 0; i < n; ++i) { scanf("%d", X + i); }
	
	int lo = -1, hi = OO;
	for(int mi = (lo + hi) / 2; hi - lo > 1; mi = (lo + hi) / 2) {
		memset(dp, -1, sizeof(dp)); dp[0][n - 1] = 1;
		if(solve(k - 1, k - 1, mi)) { hi = mi; }
		else { lo = mi; }
	}

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

Compilation message

sparklers.cpp: In function 'bool solve(int, int, int)':
sparklers.cpp:20:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   20 |  return dp[l][r] = solve(l - 1, r, s) | solve(l, r + 1, s);
      |         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp: In function 'int main()':
sparklers.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d%d%d", &n, &k, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:25:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  for(int i = 0; i < n; ++i) { scanf("%d", X + i); }
      |                               ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 4188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 4188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 4188 KB Output isn't correct
2 Halted 0 ms 0 KB -