제출 #1329547

#제출 시각아이디문제언어결과실행 시간메모리
1329547nariman_mt87Bubble Sort 2 (JOI18_bubblesort2)C++20
60 / 100
9091 ms5144 KiB
#include "bubblesort2.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long int
#define lli long long int
#define pii pair<ll,ll>
#define all(x) x.begin(),x.end()
#define mk make_pair
#define pb push_back
#define se  second
#define fi first
#define nn '\n'
#define lc (id << 1)
#define rc ((id << 1) ^ 1)
#define mid (l + r) / 2
#define txt freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define T int T;cin>>T;while(T--)
#define ashar(x) fixed<<setprecision(x)
#define migmig ios_base::sync_with_stdio(0);cin.tie(0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const lli maxn = 1e6 + 10, mod = 998244353, sq = 400, lg = 60, inf = 1e9;
ll n, m, k;
ll b[maxn];
std::vector<int> countScans(std::vector<int> a,std::vector<int> x,std::vector<int> v){
	n = a.size();
	for(int i = 1; i < n; i++){
		for(int j = 0; j < i; j++){
			b[i] += (a[i] < a[j]);
		}
	}
	m = x.size();
	vector<int> ans;
	ll mx = 0;
	for(int j = 0; j < m; j++){
		mx = 0;
		b[x[j]] = 0;
		for(int i = 0; i < x[j]; i++) b[x[j]] += (v[j] < a[i]);
		for(int i = x[j] + 1; i < n; i++) b[i] += (v[j] > a[i]) - (a[x[j]] > a[i]);
		for(int i = 0; i < n; i++) mx = max(mx, b[i]);
		ans.pb(mx);
		a[x[j]] = v[j];
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...