| Task: | Kyselyt |
| Sender: | Kuha |
| Submission time: | 2025-12-20 15:57:51 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 16 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 16 |
| #2 | TIME LIMIT EXCEEDED | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.29 s | 1, 2, 3 | details |
| #2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
Code
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
using namespace std;
int x[222222];
bool u[222222];
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
int n, q;
cin>>n>>q;
for (int i = 1; i <= n; i++) {
cin>>x[i];
}
while (q --> 0) {
int a, b;
cin>>a>>b;
int ans = 0;
int i = b;
for (int j = b; j >= a; j--) {
while (i >= a && 2 * x[i] > x[j]) {
i--;
}
if (i < a) break;
if (!u[j]) {
ans++;
u[i] = 1;
i--;
}
}
for (int i = a; i <= b; i++) {
u[i] = 0;
}
cout<<ans<<endl;
}
}Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 200000 1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| 97730 98017 97642 98714 98684 ... |
| user output |
|---|
| 97730 98017 97642 98714 98684 ... |
Test 2
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 200000 200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| 98585 98296 97821 97536 97126 ... |
| user output |
|---|
| (empty) |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 200000 200000 1682 5103 11595 22085 22347 26... |
| correct output |
|---|
| 98161 98619 98358 98614 98192 ... |
| user output |
|---|
| (empty) |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 44 990 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| 0 1 1 2 2 ... |
| user output |
|---|
| 0 1 1 2 2 ... |
