제출 #1329492

#제출 시각아이디문제언어결과실행 시간메모리
1329492mhn_neekBubble Sort 2 (JOI18_bubblesort2)C++20
60 / 100
9090 ms5152 KiB
#include "bubblesort2.h"
//In the name of God
#include<bits/stdc++.h>
using namespace std;
typedef int lli;
typedef long double ld;
typedef pair<lli,lli> pii;
typedef pair<pii,pii> piiii;
typedef vector<lli> ve;
typedef vector<pii> vp;
const lli N=3e5+100;
const lli mod=1e9+7;//998244353;//1e9+9
const lli INF=1e18;
lli power(lli x,lli y){lli res = 1;x = x % mod;while(y>0){if( y & 1 ){res = (res * x) % mod;}y = y >> 1;x = (x * x)%mod;}return res;}
lli modinv(lli x){return power(x,mod-2);}
lli divide(lli x,lli y){return ((x%mod) * modinv(y))%mod;}
#define all(v) v.begin(),v.end()
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define migmig ios_base::sync_with_stdio(false),cout.tie(0), cin.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define minheap priority_queue<pair<lli,pii>, std::vector<pair<lli,pii>>, std::greater<pair<lli,pii>>>
#define set_preci(x) cout << fixed << setprecision(x);
#define debug(x) cerr << (#x) << " " << (x) << endl
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define SUM(v) accumulate(v.begin(),v.end(), 0LL)
#define FOR(x,n) for(lli x = 0; x < n; x++)
#define FORS(x,n) for(lli x = 1; x <= n; x++)
#define TEST int TQPWIEJR; cin>>TQPWIEJR;while(TQPWIEJR--)
#define BN(l,a) while(l){a.PB(l%2);l/=2;}
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define sep " "
#define SZ(X) (lli)X.size()
lli tmp;
lli A[N];
lli q,n;
lli f[N];

lli calc(){
	lli res = 0;
	FOR(i,n)res = max(res,f[i]);
	return res;
}

ve countScans(ve v,ve X,ve V){
	q=SZ(X);
	n = SZ(v);
	FOR(i,n)A[i] = v[i];
	FOR(i,n){
		FOR(j,i){
			f[i] += (A[i] < A[j]);
		}
	}



	ve Ans;
	FOR(i,q){
		lli in = X[i],val = V[i];
		for(lli j= in + 1;j < n; j ++){
			f[j] -= (A[j] < A[in]);
			f[j] += (A[j] < val);
		}
		A[in] = val;
		f[in] = 0;
		FOR(j,in)f[in] += (A[in] < A[j]);
		// FOR(j,n){
		// 	debug(f[j]);
		// }
		// cerr<<endl;
		Ans.PB(calc());
	}
	return Ans;
}

컴파일 시 표준 에러 (stderr) 메시지

bubblesort2.cpp:13:15: warning: overflow in conversion from 'double' to 'lli' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
   13 | const lli INF=1e18;
      |               ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...