제출 #1329521

#제출 시각아이디문제언어결과실행 시간메모리
1329521itsKiaRashBubble Sort 2 (JOI18_bubblesort2)C++20
38 / 100
9089 ms2620 KiB
#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds; // find_by_order   order_of_key
// template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
// #pragma GCC optimize ("O2,unroll-loops")
// #pragma GCC optimize ("Ofast")
// #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
//#define int ll
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define file_init freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define testc int ttt;cin>>ttt;while(ttt--)
#define alll(x)	(x).begin(),(x).end()
#define pqi priority_queue<pii, vector<pii>, greater<pii>>
#define kill(x)  cout << x << '\n', exit(0)
#define rep(x) cerr<<"report: "<<x<<endl;
#define endl '\n'
#define pb push_back
#define ins insert
#define pii pair<int, int>
#define ff first
#define ss second
#define bg begin
#define rbg rbegin
#define sz size()
#define mset(x,y) memset(x,y,sizeof(x))
#define clr clear()
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define vci vector<int>
#define sti set<int>
#define nl cout<<endl
#define upb upper_bound
#define lrb lower_bound
//ll pw(ll a,ll b){ll res=1;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b);}
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
const ll inf = (ll)1e18 + 18;
const int maxn = 2e5 + 7, mod = 1e9 + 7; //998244353 1594778359 1540481779
ll n, maxi;
ll val[maxn], a[maxn];

vci countScans(vci A, vci X, vci V){
	n = A.sz;
	int q = X.sz;
	for(int i = 0 ; i < n ; i ++) a[i] = A[i];
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < i ; j ++){
			if(a[j] > a[i]) val[i] ++;
		} maxi = max(maxi, val[i]);
	}
	vci ans;
	for (int j = 0 ; j < q ; j ++) {
		int x = X[j], v = V[j];
		for(int i = x + 1 ; i < n ; i ++){
			if(a[x] > a[i]) val[i] --;
			if(v > a[i]) val[i] ++;
		} a[x] = v; maxi = 0; val[x] = 0;
		for(int i = 0 ; i < x ; i ++) if(a[i] > a[x]) val[x] ++;
		for(int i = 0 ; i < n ; i ++) maxi = max(maxi, val[i]);
		ans.pb(maxi);
	}
	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...