QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#245580 | #5488. Platform Placing | momen159# | WA | 0ms | 3708kb | C++14 | 1.4kb | 2023-11-10 03:25:55 | 2023-11-10 03:25:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define momen ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define ld long double
#define fp(n) for(int i=0;i<n;i++)
#define fp1(n) for(int i=1;i<=n;i++)
#define all(v) v.begin() , v.end()
const int mod = 1e9 + 7, N = 2e5 + 5, M = 8e6 + 5;
const ll LG = 20, inf = 1e9 + 6;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
void solve(int z) {
int n ;
double l,r;
cin>>n>>l>>r;
vector<int>v(n) ;
for (int i = 0; i < n; ++i) {
cin>>v[i] ;
}
sort(all(v)) ;
double ans = 0 ;
double dif = v[1] - v[0] ;
dif -= l/2 ;
if (dif < l/2)
return void(cout<<-1) ;
ans += min(r ,dif * 2) ;
double cur = max(l/2 , (dif+l/2) - min(r/2 , dif)) ;
for (int i = 2; i < n; ++i) {
dif = v[i] - v[i-1] ;
if (dif < l)
return void(cout<<-1) ;
double move = min( dif - l/2 , cur ) ;
ans+= move*2 ;
cur = dif - move ;
}
ans+= cur*2 ;
cout<<ans ;
}
int main() {
momen
int t = 1;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
// cin >> t;
for (int i = 1; i <= t; ++i) {
//cout<<"Case #"<<i<<": ";
solve(t);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3708kb
input:
1 1 100 1
output:
-1
result:
wrong answer 1st lines differ - expected: '100', found: '-1'