Submission #1208031

#TimeUsernameProblemLanguageResultExecution timeMemory
1208031mychecksedadSparklers (JOI17_sparklers)C++20
0 / 100
0 ms320 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30; int n, k; ll t, a[N]; void solve(){ cin >> n >> k >> t; for(int i = 1; i <= n; ++i){ cin >> a[i]; } ll l = 0, r = 1e9, ans = 1e9; while(l <= r){ ll mid = l+r>>1; bool ok = false; for(int mask = 0; mask < (1<<(n-1)); ++mask){ if(__builtin_popcount(mask) != k - 1) continue; // 1's go left, 0's go right ll mn = a[k], mx = a[k]; bool oo = true; int L = k, R = k; if(mid == 7) for(int i = 0; i < n-1; ++i){ if((1<<i)&mask){ // if(mid==7){ // cerr << i << ' ' << a[L] + (a[R] - a[L + 1]) << '\n'; // } --L; // we will get a[L-1] if(mn > a[L] + (a[R] - mn) + t * mid * 2){ oo = false; break; } mx = a[L] + (a[R] - mn) + t * mid; mn = mn - t * mid; }else{ ++R; // we will get a[L-1] if(mx < a[R] - (mx - a[L]) - t * mid * 2){ oo = false; break; } mn = a[R] - (mx - a[L]) - t * mid; mx = mx + t * mid; } } if(oo){ ok = 1; break; } } if(ok){ ans = mid; r = mid-1; }else l = mid+1; } cout << ans; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(tt--){ solve(); en; } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...