QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#441135 | #8781. Element-Wise Comparison | HKOI0 | WA | 2ms | 10040kb | C++14 | 1.0kb | 2024-06-14 13:11:17 | 2024-06-14 13:11:17 |
Judging History
answer
#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
#define int long long
using namespace std;
const int N = 5e4 + 11;
typedef bitset<N> BIT;
int a[N];
BIT c[N], pf[N], sf[N];
void solve(){
int n, m; cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
BIT I; for (int i = 0; i < N; i++) I[i] = 1;
BIT cur;
vector<pair<int, int>> b;
for (int i = 0; i < n; i++) {
b.push_back({a[i], i});
}
sort(b.begin(), b.end(), greater<pair<int, int>>());
for (auto [val, idx] : b) {
c[idx] = (I << (idx + 1)) & cur;
cur[idx] = 1;
}
for (int i = 0; i < n; i++) {
if (i % m) pf[i] = c[i] & pf[i - 1];
else pf[i] = c[i];
if (i % m != m - 1) sf[i] = c[i] & sf[i + 1];
else sf[i] = c[i];
}
int ans = 0;
for (int i = 0; i <= n - m; i++) {
ans += (pf[i] & sf[i]).count();
}
cout << ans << '\n';
}
int32_t main(){
#ifndef LOCAL
cin.tie(0); cout.tie(0)->sync_with_stdio(false);
#endif
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 10040kb
input:
5 3 5 2 1 3 4
output:
0
result:
ok answer is '0'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 7768kb
input:
5 2 3 1 4 2 5
output:
3
result:
wrong answer expected '2', found '3'