QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#188327 | #5488. Platform Placing | triplem5ds# | WA | 1ms | 3544kb | C++23 | 1.6kb | 2023-09-25 19:00:18 | 2023-09-25 19:00:19 |
Judging History
answer
/// Msaa el 5ra
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for(int i = a; i < b; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll
using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;
const int N = 5e5 + 5, LG = 18, MOD = 1e9 + 7;
const long double PI = acos(-1);
const long double EPS = 1e-7;
void doWork() {
int n, l, r;
cin >> n >> l >> r;
vector<ii> ranges;
vector<int> vec(n);
f(i, 0, n) {
cin >> vec[i];
vec[i] *= 2;
}
sort(all(vec));
ranges.push_back({0, 0});
f(i, 0, n) {
int x = vec[i];
if (ranges.empty() || ranges.back().S <= x - l)
ranges.push_back({x - l, x + l});
}
int ans = ranges.size() * l - l;
for (int i = 1; i < ranges.size(); i++) {
int add = r - l;
if (i)add = min(add, ranges[i].F - ranges[i - 1].S);
if (i + 1 != ranges.size())add = min(add, ranges[i + 1].F - ranges[i].S);
ranges[i].F -= add;
ranges[i].S += add;
ans += add;
}
if (ans == 0)ans = -1;
cout << ans << '\n';
}
int32_t main() {
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif // ONLINE_JUDGE
int t = 1;
// cin >> t;
while (t--) {
doWork();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3544kb
input:
1 1 100 1
output:
2
result:
wrong answer 1st lines differ - expected: '100', found: '2'