답안 #423370

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
423370 2021-06-11T03:32:29 Z balbit Sparklers (JOI17_sparklers) C++14
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define y1 zck_is_king
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define REP(i,n) for (int i = 0; i<n; ++i)
#define RREP(i,n) for (int i = n-1; i>=0; --i)
#define REP1(i,n) for (int i = 1; i<=n; ++i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1e9+10;
const ll inf = 2e18+10000;
const ll mod = 1e9+7 ;


void GG(){cout<<"0\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b,mo) % mo;
}

const int maxn = 1e6+5;

signed main(){
    IOS();
    int n,k,T; cin>>n>>k>>T;
    --k;
    vector<ll> X(n);
    REP(i,n) {
        cin>>X[i];
    }
    vector<ll> L, R;
    int st = 0;
    REP(i,n) {
        if (X[i] < X[k]) {
            L.pb(X[k] - X[i]);
        }
        if (X[i] > X[k]) {
            R.pb(X[i] - X[k]);
        }
        if (X[i] == X[k]) {
            ++st;
        }
    }
    RREP(i, SZ(L)) if (i) L[i] -= L[i-1];
    RREP(i, SZ(R)) if (i) R[i] -= R[i-1];
    L.pb(inf);
    R.pb(inf);
    for (int x : L) bug(x);
    for (int x : R) bug(x);

    bug(st);
    ll l = 0, r = 1e9+5;
    while (l!=r) {
        ll s = (l+r)/2;
        ll pts = min((__int128) inf, st * (__int128) T * (__int128)s * 2);
        int i = 0, j = 0;
        bool ok = 1;
        REP(cnt, SZ(L) + SZ(R) - 2) {
            if (L[i] < R[j]) {
                pts -= L[i];
                ++i;
            }else{
                pts -= R[i];
                ++j;
            }
            if (pts < 0) {
                ok = 0; break;
            }
            pts += T * s * 2;
            MN(pts, inf);
        }
        bug(i,j);
        if (ok ) {
            r=s;
        }else{
            l=s+1;
        }
    }
    cout<<l<<endl;

}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:80:14: warning: unused variable 'x' [-Wunused-variable]
   80 |     for (int x : L) bug(x);
      |              ^
sparklers.cpp:81:14: warning: unused variable 'x' [-Wunused-variable]
   81 |     for (int x : R) bug(x);
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -