답안 #769332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
769332 2023-06-29T12:27:45 Z Dan4Life Bubble Sort 2 (JOI18_bubblesort2) C++17
0 / 100
9000 ms 5212 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
using vi = vector<int>;
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = (int)1e2+10;
template<class T> using Tree = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
Tree<int> S[mxN];

vi countScans(vi A, vi X, vi V){
    int q = sz(X), n = sz(A); vi ans, a(all(A));
	for(int i = 0; i < n; i++) S[a[i]].insert(i);
    for(int _ = 0; _ < q; _++){
		S[a[X[_]]].erase(X[_]);
        a[X[_]] = V[_]; 
		S[a[X[_]]].insert(X[_]);
        int tot = 0;
		for(int i = 1; i < mxN; i++){
			if(S[i].empty()) continue;
			int sum = 0; int p = *(--S[i].end());
			for(int j = i+1; j < mxN; j++){
				if(S[j].empty()) continue;
				sum+=S[j].order_of_key(p);
			}
			auto itr = *(--S[i].end());
			tot = max(tot, sum);
		}
        ans.pb(tot);
    }
	return ans;
}

Compilation message

bubblesort2.cpp: In function 'vi countScans(vi, vi, vi)':
bubblesort2.cpp:28:9: warning: unused variable 'itr' [-Wunused-variable]
   28 |    auto itr = *(--S[i].end());
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 471 ms 2084 KB Output is correct
2 Correct 4626 ms 3372 KB Output is correct
3 Correct 8827 ms 4924 KB Output is correct
4 Execution timed out 9007 ms 5212 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -