답안 #884064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884064 2023-12-06T15:17:12 Z vjudge1 Bubble Sort 2 (JOI18_bubblesort2) C++17
22 / 100
345 ms 6544 KB
#include "bubblesort2.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int , int> , null_type, less<pair<int , int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

std::vector<int> countScans(std::vector<int> a,std::vector<int> X,std::vector<int> V){
	int Q=X.size();
	int n = a.size();
	std::vector<int> answer(Q);

    priority_queue<int> q[101];

    orderedSet s;
    for (int i = 0; i < n; i++)
    {
        s.insert ({a[i] , i});
        q[a[i]].push(i);
    }


    for (int j = 0; j < Q; j++)
    {
        s.erase({a[X[j]] , X[j]});
        a[X[j]] = V[j];
        s.insert({a[X[j]] , X[j]});
        q[a[X[j]]].push(X[j]);
        for (int val = 1; val <= 100; val++)
        {
            while (q[val].size() && a[q[val].top()] != val) q[val].pop();
            if (q[val].size())
            {
                answer[j] = max(answer[j] , q[val].top() - (int)s.order_of_key({val, q[val].top()}));
            }
        }
    }

	return answer;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2628 KB Output is correct
2 Correct 160 ms 4204 KB Output is correct
3 Correct 325 ms 5968 KB Output is correct
4 Correct 328 ms 5968 KB Output is correct
5 Correct 345 ms 6312 KB Output is correct
6 Correct 304 ms 6056 KB Output is correct
7 Correct 305 ms 6024 KB Output is correct
8 Correct 301 ms 5852 KB Output is correct
9 Correct 293 ms 6544 KB Output is correct
10 Correct 185 ms 5840 KB Output is correct
11 Correct 207 ms 5840 KB Output is correct
12 Correct 186 ms 5836 KB Output is correct
13 Correct 181 ms 5668 KB Output is correct
14 Correct 187 ms 5700 KB Output is correct
15 Correct 188 ms 5640 KB Output is correct
16 Correct 185 ms 5580 KB Output is correct
17 Correct 194 ms 5592 KB Output is correct
18 Correct 180 ms 5516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -