답안 #1091987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091987 2024-09-22T18:55:31 Z thangdz2k7 Sparklers (JOI17_sparklers) C++17
50 / 100
21 ms 1468 KB
// author : thembululquaUwU
// 3.9.2024

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define endl '\n'

using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;

const int N = 1e3 + 5;
const int mod = 1e9 + 7;

void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}

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

bool dp[N][N];

bool check(ll s) {
	memset(dp, 0, sizeof dp);
	dp[k][k] = 1;
	for (int len = 2; len <= n; ++ len) {
		for (int l = 1; l <= n; ++ l) {
			int r = l + len - 1;
			if (r > n) {
				break;
			}
			dp[l][r] = ((dp[l + 1][r] || dp[l][r - 1]) && (x[r] - x[l]) <= 2 * s * (r - l) * t);
		}
	}
	return dp[1][n];
}

void solve(){
    cin >> n >> k >> t;
    for (int i = 1; i <= n; ++ i) cin >> x[i];
    int lo = 0, hi = x[n] / t + 1, ans = hi;
    while (lo <= hi){
        int mid = lo + hi >> 1;
        if (check(mid)) ans = mid, hi = mid - 1;
        else lo = mid + 1;
    }
    cout << ans;
}

signed main(){
    if (fopen("pqh.inp", "r")){
        freopen("pqh.inp", "r", stdin);
        freopen("pqh.out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1; // cin >> t;
    while (t --) solve();
    return 0;
}

Compilation message

sparklers.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
sparklers.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
sparklers.cpp:20:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
sparklers.cpp:20:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
sparklers.cpp: In function 'void solve()':
sparklers.cpp:46:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |         int mid = lo + hi >> 1;
      |                   ~~~^~~~
sparklers.cpp: In function 'int main()':
sparklers.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen("pqh.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:56:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         freopen("pqh.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1368 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1372 KB Output is correct
9 Correct 1 ms 1368 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1372 KB Output is correct
15 Correct 1 ms 1444 KB Output is correct
16 Correct 1 ms 1372 KB Output is correct
17 Correct 1 ms 1372 KB Output is correct
18 Correct 1 ms 1372 KB Output is correct
19 Correct 1 ms 1368 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1368 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1372 KB Output is correct
9 Correct 1 ms 1368 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1372 KB Output is correct
15 Correct 1 ms 1444 KB Output is correct
16 Correct 1 ms 1372 KB Output is correct
17 Correct 1 ms 1372 KB Output is correct
18 Correct 1 ms 1372 KB Output is correct
19 Correct 1 ms 1368 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1372 KB Output is correct
22 Correct 12 ms 1372 KB Output is correct
23 Correct 6 ms 1372 KB Output is correct
24 Correct 8 ms 1372 KB Output is correct
25 Correct 16 ms 1372 KB Output is correct
26 Correct 16 ms 1372 KB Output is correct
27 Correct 21 ms 1372 KB Output is correct
28 Correct 18 ms 1372 KB Output is correct
29 Correct 16 ms 1464 KB Output is correct
30 Correct 20 ms 1372 KB Output is correct
31 Correct 17 ms 1468 KB Output is correct
32 Correct 18 ms 1372 KB Output is correct
33 Correct 20 ms 1468 KB Output is correct
34 Correct 18 ms 1372 KB Output is correct
35 Correct 19 ms 1468 KB Output is correct
36 Correct 18 ms 1372 KB Output is correct
37 Correct 17 ms 1468 KB Output is correct
38 Correct 18 ms 1464 KB Output is correct
39 Correct 17 ms 1464 KB Output is correct
40 Correct 2 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1368 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1372 KB Output is correct
9 Correct 1 ms 1368 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1372 KB Output is correct
15 Correct 1 ms 1444 KB Output is correct
16 Correct 1 ms 1372 KB Output is correct
17 Correct 1 ms 1372 KB Output is correct
18 Correct 1 ms 1372 KB Output is correct
19 Correct 1 ms 1368 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1372 KB Output is correct
22 Correct 12 ms 1372 KB Output is correct
23 Correct 6 ms 1372 KB Output is correct
24 Correct 8 ms 1372 KB Output is correct
25 Correct 16 ms 1372 KB Output is correct
26 Correct 16 ms 1372 KB Output is correct
27 Correct 21 ms 1372 KB Output is correct
28 Correct 18 ms 1372 KB Output is correct
29 Correct 16 ms 1464 KB Output is correct
30 Correct 20 ms 1372 KB Output is correct
31 Correct 17 ms 1468 KB Output is correct
32 Correct 18 ms 1372 KB Output is correct
33 Correct 20 ms 1468 KB Output is correct
34 Correct 18 ms 1372 KB Output is correct
35 Correct 19 ms 1468 KB Output is correct
36 Correct 18 ms 1372 KB Output is correct
37 Correct 17 ms 1468 KB Output is correct
38 Correct 18 ms 1464 KB Output is correct
39 Correct 17 ms 1464 KB Output is correct
40 Correct 2 ms 1372 KB Output is correct
41 Runtime error 1 ms 604 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -