# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
727101 | 2023-04-20T03:54:55 Z | Baytoro | Measures (CEOI22_measures) | C++17 | 1500 ms | 460 KB |
#include <bits/stdc++.h> using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define endl '\n' #define ll long long #define int long long void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const ll INF=1e18,mod=1e9+9,N=2e5+5; int d; int calc(vector<int> vec){ sort(all(vec)); int n=vec.size(); int l=-1,r=2e9; while(r-l>1){ int md=(l+r)/2; vector<int> a=vec; for(int i=0;i<n;i++){ if(!i){ a[i]-=md; continue; } int x=abs((a[i-1]+d)-a[i]); //cout<<x<<endl; if(x>md){ if(a[i]-md<a[i-1]+d) a[i]+=md; else a[i]-=md; } else{ if(a[i]-x<a[i-1]+d) a[i]+=x; else a[i]-=x; } /*cout<<md<<endl; for(auto it: a) cout<<it<<' '; cout<<endl;*/ } bool check=1; for(int i=1;i<n && check;i++) check&=(a[i]-a[i-1]>=d); if(check) r=md; else l=md; } return r; } void solve(){ int n,m;cin>>n>>m>>d; d*=2; vector<int> vec(n); for(int i=0;i<n;i++){ cin>>vec[i]; vec[i]*=2; } for(int i=0;i<m;i++){ int x;cin>>x; vec.pb(2*x); int ans=calc(vec); cout<<ans/2; if(ans%2) cout<<".5"; cout<<' '; } } main(){ //fopn("friendcross"); ios; int T=1; //cin>>T; for(int i=1;i<=T;i++){ //cout<<"Case #"<<i<<": "; solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 340 KB | Output is correct |
2 | Correct | 5 ms | 340 KB | Output is correct |
3 | Correct | 5 ms | 332 KB | Output is correct |
4 | Correct | 5 ms | 340 KB | Output is correct |
5 | Correct | 5 ms | 340 KB | Output is correct |
6 | Correct | 5 ms | 332 KB | Output is correct |
7 | Correct | 6 ms | 340 KB | Output is correct |
8 | Incorrect | 4 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 340 KB | Output is correct |
2 | Correct | 5 ms | 340 KB | Output is correct |
3 | Correct | 5 ms | 332 KB | Output is correct |
4 | Correct | 5 ms | 340 KB | Output is correct |
5 | Correct | 5 ms | 340 KB | Output is correct |
6 | Correct | 5 ms | 332 KB | Output is correct |
7 | Correct | 6 ms | 340 KB | Output is correct |
8 | Incorrect | 4 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1575 ms | 460 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1575 ms | 460 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |