QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#222096 | #7617. Spectacle | ucup-team1329# | WA | 0ms | 3456kb | C++17 | 2.1kb | 2023-10-21 15:47:55 | 2023-10-21 15:47:55 |
Judging History
answer
#include <bits/stdc++.h>
#define i64 long long
#define endl '\n'
#define lg(x) ((int)log10(x))
#define log(x) ((int)log2(x))
#define PII std::pair<i64, i64>
#define val first
#define id second
#define Fast_IOS std::ios::sync_with_stdio(false),std::cin.tie(0);
#define debug(x) std::cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<'\n';
const i64 mod = 998244353;
namespace SEG {
int n;
std::vector<i64> sum, pre, suf, ans;
#define ls x << 1
#define rs x << 1 | 1
void pushup(int x, int l, int r) {
int mid = l + r >> 1;
sum[x] = sum[ls] + sum[rs];
pre[x] = (pre[ls] == mid - l + 1 ? pre[ls] + pre[rs] : pre[ls]);
suf[x] = (suf[rs] == r - mid ? suf[rs] + suf[ls] : suf[rs]);
ans[x] = ans[ls] + ans[rs] - (pre[rs] + 1) / 2 - (suf[ls] + 1) / 2 + (pre[rs] + suf[ls] + 1) / 2;
}
void build(int x, int l, int r) {
if (l == r) {
sum[x] = pre[x] = suf[x] = ans[x] = 1;
return;
}
int mid = l + r >> 1;
build(ls, l, mid);
build(rs, mid + 1, r);
pushup(x, l, r);
}
void init(int t) {
n = t;
sum.resize(n << 2);
pre.resize(n << 2);
suf.resize(n << 2);
ans.resize(n << 2);
build(1, 1, n);
}
void modify(int P, int x = 1, int l = 1, int r = n) {
if (l == r) {
sum[x] = pre[x] = suf[x] = ans[x] = 0;
return;
}
int mid = l + r >> 1;
if (mid >= P) modify(P, ls, l, mid);
else modify(P, rs, mid + 1, r);
pushup(x, l, r);
}
};
void solve() {
int n;
std::cin >> n;
n--;
std::vector<int> c(n + 2);
std::vector<PII> a(n + 1);
for (int i = 1; i <= n + 1; i++) {
std::cin >> c[i];
}
std::sort(c.begin() + 1, c.end());
for (int i = 1; i <= n; i++) {
a[i].val = c[i + 1] - c[i];
a[i].id = i;
}
SEG::init(n);
std::sort(a.begin() + 1, a.end());
std::reverse(a.begin() + 1, a.end());
std::vector<i64> ans(n + 1);
for (int i = 1; i <= n; i++) {
i64 x = SEG::ans[1];
ans[x] = a[i].val;
SEG::modify(a[i].id);
}
for (int i = 1; i <= (n + 1) / 2; i++) {
std::cout << ans[i] << ' ';
}
std::cout << endl;
}
int main() {
Fast_IOS
int T = 1;
// std::cin >> T;
while (T--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3432kb
input:
6 100 13 20 14 10 105
output:
1 5 6
result:
ok single line: '1 5 6 '
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3456kb
input:
2 1 1000000000000000000
output:
2147483646
result:
wrong answer 1st lines differ - expected: '999999999999999999', found: '2147483646 '