QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#245579 | #5488. Platform Placing | momen159# | WA | 0ms | 3700kb | C++14 | 1.6kb | 2023-11-10 03:24:45 | 2023-11-10 03:24:47 |
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};
int adj[N] , in[N];
ll ans[N] ;
ll answer = 1 ;
bool vis[N] ;
ll dfs(int i){
if (vis[i])
return 1;
vis[i] = 1;
ll ret = ans[i] ;
ret*= dfs(adj[i]) ;
ret%=mod ;
return ret ;
}
void solve(int z) {
double n , l,r;
cin>>n>>l>>r;
vector<int>v(n) ;
for (int i = 0; i < n; ++i) {
cin>>v[i] ;
}
sort(all(v)) ;
ll 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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3700kb
input:
1 1 100 1
output:
-1
result:
wrong answer 1st lines differ - expected: '100', found: '-1'