제출 #1292099

#제출 시각아이디문제언어결과실행 시간메모리
1292099HoriaHaivasMeasures (CEOI22_measures)C++20
24 / 100
1595 ms3568 KiB
#include<bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " #pragma GCC optimize("Ofast") #define int long long using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int range_rng(int l, int r) { return uniform_int_distribution<int>(l,r)(rng); } long long dp[200105]; long long coord[200105]; int n,d; bool ok(long long x) { int i; for (i=1; i<=n; i++) { if (i==1) dp[i]=coord[i]-x; else { if (coord[i]-dp[i-1]>=d) dp[i]=coord[i]-min(coord[i]-dp[i-1]-d,x); else { if (coord[i]+x<dp[i-1]+d) return false; else dp[i]=dp[i-1]+d; } } } return true; } signed main() { /* ifstream fin("arbore.in"); ofstream fout("arbore.out"); */ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int m,i,j,pas,x; long long r,z; cin >> n >> m >> d; d*=2; for (i=1; i<=n; i++) { cin >> coord[i]; coord[i]*=2; } for (i=1; i<=m; i++) { cin >> x; n++; coord[n]=x*2; sort(coord+1,coord+1+n);///imi e lene sa fac liniar if (n==1) { cout << "0 "; continue; } r=0; pas=(1LL<<60); while (pas) { if (!ok(r+pas)) r+=pas; pas=pas/2; } if (ok(r)) cout << r << " "; else if (ok(r+1)) { if (r%2==1) cout << (r+1)/2 << " "; else cout << r/2 << ".5" << " "; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...