Submission #62803692


Source Code Expand

Copy
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
int main() {
int n, q;
std::cin >> n >> q;
std::vector<int> a(n);
for (auto &ai : a) std::cin >> ai;
std::vector<std::pair<std::pair<int, int>, int>> queries(q);
for (int i = 0; auto &[query, idx] : queries) {
auto &[r, x] = query;
std::cin >> r >> x;
r--;
idx = i++;
}
std::ranges::sort(queries);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

int main() {
    int n, q;
    std::cin >> n >> q;

    std::vector<int> a(n);
    for (auto &ai : a) std::cin >> ai;

    std::vector<std::pair<std::pair<int, int>, int>> queries(q);
    for (int i = 0; auto &[query, idx] : queries) {
        auto &[r, x] = query;
        std::cin >> r >> x;
        r--;
        idx = i++;
    }

    std::ranges::sort(queries);
    int query_idx = 0;

    std::vector<int> ans(q);

    std::vector<int> lis{0};
    for (int i = 0; i < n; i++) {
        auto iter = std::ranges::lower_bound(lis, a[i]);
        if (iter == lis.end()) {
            lis.push_back(a[i]);
        } else if (*iter != a[i]) {
            lis[std::distance(lis.begin(), iter)] = a[i];
        }

        while (query_idx < q) {
            auto &[query, idx] = queries[query_idx];
            auto &[r, x] = query;
            if (r > i) break;

            ans[idx] = std::distance(lis.begin(), std::prev(std::ranges::upper_bound(lis, x)));
            query_idx++;
        }
    }

    for (const auto &ai : ans) std::cout << ai << std::endl;
    return 0;
}

Submission Info

Submission Time
Task F - Prefix LIS Query
User iis914
Language C++ 20 (gcc 12.2)
Score 500
Code Size 1199 Byte
Status AC
Exec Time 353 ms
Memory 8168 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 37
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 03_random3_05.txt, 03_random3_06.txt, 03_random3_07.txt, 03_random3_08.txt, 03_random3_09.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3480 KB
00_sample_01.txt AC 1 ms 3612 KB
01_random_00.txt AC 1 ms 3496 KB
01_random_01.txt AC 263 ms 6336 KB
01_random_02.txt AC 59 ms 3848 KB
01_random_03.txt AC 64 ms 3928 KB
01_random_04.txt AC 165 ms 4868 KB
01_random_05.txt AC 220 ms 5440 KB
01_random_06.txt AC 349 ms 7080 KB
01_random_07.txt AC 351 ms 6996 KB
01_random_08.txt AC 349 ms 7160 KB
01_random_09.txt AC 349 ms 7088 KB
01_random_10.txt AC 350 ms 7164 KB
01_random_11.txt AC 348 ms 7076 KB
01_random_12.txt AC 348 ms 7032 KB
01_random_13.txt AC 353 ms 7080 KB
01_random_14.txt AC 349 ms 7028 KB
02_random2_00.txt AC 344 ms 7072 KB
02_random2_01.txt AC 346 ms 7020 KB
02_random2_02.txt AC 344 ms 7140 KB
02_random2_03.txt AC 345 ms 7024 KB
02_random2_04.txt AC 349 ms 7024 KB
03_random3_00.txt AC 348 ms 8016 KB
03_random3_01.txt AC 334 ms 7080 KB
03_random3_02.txt AC 349 ms 8044 KB
03_random3_03.txt AC 332 ms 7016 KB
03_random3_04.txt AC 350 ms 8024 KB
03_random3_05.txt AC 335 ms 6984 KB
03_random3_06.txt AC 350 ms 8096 KB
03_random3_07.txt AC 336 ms 7080 KB
03_random3_08.txt AC 351 ms 8168 KB
03_random3_09.txt AC 343 ms 7140 KB
04_handmade_00.txt AC 330 ms 7024 KB
04_handmade_01.txt AC 309 ms 8088 KB
04_handmade_02.txt AC 318 ms 7088 KB
04_handmade_03.txt AC 309 ms 7020 KB
04_handmade_04.txt AC 311 ms 8076 KB


2025-04-29 (Tue)
00:01:42 +00:00