Submission #354607

# Submission time Handle Problem Language Result Execution time Memory
354607 2021-01-22T04:27:07 Z Lam_lai_cuoc_doi Sparklers (JOI17_sparklers) C++17
0 / 100
1 ms 384 KB
#include <iostream>
#include <cstdio>
#include <cmath>
#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)
{
    int a(k), b(k);
    while (a > 1 || b < n)
    {
        bool flag(1);
        if (a > 1 && b < n && 4ll * T >= ceil((ld)1.0 * (x[b + 1] - x[a - 1] - (x[b] - x[a])) / v))
        {
            flag = 0;
            --a;
            ++b;
        }
        else if (a > 1 && 2ll * T * (b + 1 - a) >= ceil((ld)1.0 * (x[b] - x[a - 1]) / v))
        {
            flag = 0;
            --a;
        }
        else if (b < n && 2ll * T * (b + 1 - a) >= ceil((ld)1.0 * (x[b + 1] - x[a]) / v))
        {
            flag = 0;
            ++b;
        }
        if (flag)
            return false;
    }
    return true;
}

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:70:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   70 |         freopen(task ".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   71 |         freopen(task ".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory 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 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 1 ms 364 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 1 ms 364 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 1 ms 364 KB Output isn't correct
8 Halted 0 ms 0 KB -