답안 #990356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990356 2024-05-30T09:46:26 Z amine_aroua Sparklers (JOI17_sparklers) C++17
0 / 100
1 ms 472 KB
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
using namespace std;
#define int long long
#define pb push_back
#define nl '\n'
#define fore(i, y) for(int i = 0; i < y; i++)
#define forr(i, x, y) for(int i = x;i<=y;i++)
#define forn(i, y, x) for(int i = y; i >= x; i--)
const int N = 1e5 + 10;
int n , k , t;
int x[N];
bool check(int s)
{
    vector<int> a , b;
    forn(i , k , 1)
        a.pb(x[i] - 2*t*s * i);
    forr(i  , k , n)
        b.pb(x[i] - 2*t*s * i);
    int mx = a[0] , mn = b[0];
    int i = 1 , j = 1;
    while(true)
    {
        if(i < (int)a.size() && a[i] >= mn)
            mx = max(mx , a[i++]);
        else if(j < (int)b.size() && b[j] <= mx)
            mn = min(mn , b[j++]);
        else
            break;
    }
    return (i == (int)a.size() && j == (int)b.size());
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k>>t;
    bool acc = 1;
    forr(i , 1 , n) {
        cin >> x[i];
        if (x[i] != 0)
            acc = 0;
    }
    if(acc)
    {
        cout<<0<<nl;
        return 0;
    }
    int lo = 0 , hi = 1e10;
    while(lo + 1 < hi)
    {
        int mid = (lo + hi)/2;
        if(check(mid))
            hi = mid;
        else
            lo = mid;
    }
    cout<<hi<<nl;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 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 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 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 472 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 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 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 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 472 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 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 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 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 472 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -