답안 #355092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
355092 2021-01-22T09:02:19 Z Lam_lai_cuoc_doi Sparklers (JOI17_sparklers) C++17
50 / 100
166 ms 262148 KB
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#define task ""
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e5 + 2;
const int Inf = 1e9 + 7;
int n, T, k;
int x[N];

void Read()
{
    cin >> n >> k >> T;
    for (int i = 1; i <= n; ++i)
        cin >> x[i];
}

bool Check(int v)
{
    vector<vector<bool>> dp(n + 5, vector<bool>(n + 5, 0));
    dp[k][k] = 1;
    for (int i = 2; i <= n; ++i)
        for (int j = 1; j <= n - i + 1; ++j)
            if ((dp[j][j + i - 2] || dp[j + 1][j + i - 1]) && (2ll * T * v >= (x[j + i - 1] - x[j]) || 2ll * T * v * (i - 1) >= (x[j + i - 1] - x[j])))
                dp[j][j + i - 1] = 1;
    return dp[1][n];
}

void Solve()
{
    int l = 0, m, h = 1e9 + 7;
    while (l <= h)
    {
        m = (l + h) / 2;
        if (!Check(m))
            l = m + 1;
        else
            h = m - 1;
    }
    cout << l;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (fopen(task ".INP", "r"))
    {
        freopen(task ".INP", "r", stdin);
        freopen(task ".OUT", "w", stdout);
    }
    Read();
    Solve();
}

Compilation message

sparklers.cpp: In function 'int32_t main()':
sparklers.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   54 |         freopen(task ".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
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(task ".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 28 ms 512 KB Output is correct
23 Correct 20 ms 364 KB Output is correct
24 Correct 26 ms 492 KB Output is correct
25 Correct 44 ms 592 KB Output is correct
26 Correct 48 ms 592 KB Output is correct
27 Correct 48 ms 592 KB Output is correct
28 Correct 52 ms 592 KB Output is correct
29 Correct 50 ms 592 KB Output is correct
30 Correct 48 ms 592 KB Output is correct
31 Correct 47 ms 692 KB Output is correct
32 Correct 49 ms 592 KB Output is correct
33 Correct 49 ms 592 KB Output is correct
34 Correct 45 ms 592 KB Output is correct
35 Correct 50 ms 592 KB Output is correct
36 Correct 45 ms 592 KB Output is correct
37 Correct 46 ms 592 KB Output is correct
38 Correct 49 ms 720 KB Output is correct
39 Correct 45 ms 592 KB Output is correct
40 Correct 50 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 28 ms 512 KB Output is correct
23 Correct 20 ms 364 KB Output is correct
24 Correct 26 ms 492 KB Output is correct
25 Correct 44 ms 592 KB Output is correct
26 Correct 48 ms 592 KB Output is correct
27 Correct 48 ms 592 KB Output is correct
28 Correct 52 ms 592 KB Output is correct
29 Correct 50 ms 592 KB Output is correct
30 Correct 48 ms 592 KB Output is correct
31 Correct 47 ms 692 KB Output is correct
32 Correct 49 ms 592 KB Output is correct
33 Correct 49 ms 592 KB Output is correct
34 Correct 45 ms 592 KB Output is correct
35 Correct 50 ms 592 KB Output is correct
36 Correct 45 ms 592 KB Output is correct
37 Correct 46 ms 592 KB Output is correct
38 Correct 49 ms 720 KB Output is correct
39 Correct 45 ms 592 KB Output is correct
40 Correct 50 ms 580 KB Output is correct
41 Runtime error 166 ms 262148 KB Execution killed with signal 9
42 Halted 0 ms 0 KB -