QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#673809 | #6104. Building Bombing | stompQ | WA | 1ms | 7648kb | C++23 | 2.1kb | 2024-10-25 10:29:40 | 2024-10-25 10:29:40 |
Judging History
answer
#include <iostream>
#include <map>
using namespace std;
int t[400005][11], lazy[400005][11], a[100005], f[100005][12];
map<int, int> m;
void push(int v, int h) {
t[v * 2][h] += lazy[v][h];
t[v * 2 + 1][h] += lazy[v][h];
lazy[v * 2][h] += lazy[v][h];
lazy[v * 2 + 1][h] += lazy[v][h];
lazy[v][h] = 0;
}
void update(int v, int h, int tl, int tr, int l, int r, int x, int fl) {
if (l > r) return;
if (tl == l && tr == r) {
if (fl == 0) t[v][h] = x;
else {
t[v][h] += x;
lazy[v][h] += x;
}
return;
}
push(v, h);
int mid = (tl + tr) / 2;
update(v * 2, h, tl, mid, l, min(r, mid), x, fl);
update(v * 2 + 1, h, mid + 1, tr, max(l, mid + 1), r, x, fl);
t[v][h] = min(t[v * 2][h], t[v * 2 + 1][h]);
}
int sum(int v, int h, int tl, int tr, int l, int r) {
if (l > r) return 1e9;
if (tl == l && tr == r) {
return t[v][h];
}
int mid = (tl + tr) / 2;
return min(sum(v * 2, h, tl, mid, l, min(r, mid)), sum(v * 2 + 1, h, mid + 1, tr, max(l, mid + 1), r));
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, l, k, z = 0;
cin >> n >> l >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
m[a[i]] = 1;
}
for (auto &w : m) w.second = ++z;
for (int i = 1; i <= n; i++) a[i] = m[a[i]];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
update(1, j, 1, z, a[i], a[i], 1e9, 0);
f[i][j] = 1e9;
}
}
update(1, 1, 1, z, a[l], a[l], 0, 0);
f[a[l]][1] = 0;
for (int i = l + 1; i <= n; i++) {
for (int j = k; j >= 2; j--) {
int h = sum(1, j - 1, 1, z, 1, a[i] - 1);
h = min(h, sum(1, j, 1, z, a[i], a[i]));
update(1, j, 1, z, a[i], a[i], h, 0);
}
for (int j = 1; j <= k; j++) {
update(1, j, 1, z, 1, a[i] - 1, 1, 1);
}
}
int res = sum(1, k, 1, z, 1, z);
for (int i = 1; i < l; i++) res += (a[i] == a[l]);
if (res >= 1e6) cout << -1;
else cout << res;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7648kb
input:
7 2 3 10 30 90 40 60 60 80
output:
1
result:
wrong answer 1st numbers differ - expected: '2', found: '1'