답안 #114252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
114252 2019-05-31T15:12:01 Z rajarshi_basu Bubble Sort 2 (JOI18_bubblesort2) C++14
0 / 100
9000 ms 1144 KB
#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <complex>
#include <stack>
#include <set>
#include <fstream>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define vi vector<int>
#define v vector
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define cd complex<double> 
#define iil pair<ii,ll>
#define v vector


const int MAXN = 5e5+10;
const int INF = 1e9+5;
using namespace std;
//int n,k;

int arr[MAXN];
int rgt[MAXN];

void calc(int n){
	FOR(i,n){
		rgt[i] = -1;
		FORE(j,i+1,n-1){
			if(arr[j] < arr[i]){
				rgt[i] = j;
			}
		}
	}
}

vi countScans(vi ar,vi xx,vi vals){
	int n = ar.size();
	FOR(i,n)arr[i] = ar[i];
	int q = vals.size();
	vi ans;ans.reserve(q);
	FOR(i,q){
		arr[xx[i]] = vals[i];
		calc(n);
		int mx = 0;
		FOR(j,n){
			if(rgt[j] == -1)continue;
			int cnt = 1;
			FOR(l,rgt[j]){
				cnt += arr[l]>arr[j];
			}
			mx = max(mx,cnt);
		}
		ans[i] = mx;
	}
	return ans;
}
/*
int main(){
	int n,q;
	cin >> n >> q;
	v<int> ar(n);
	
	FOR(i,n){
		cin >> ar[i];
	}
	v<int> x(q),vals(q);
	x.reserve(q);
	vals.reserve(q);

	FOR(i,q){
		cin >> x[i] >> vals[i];
	}

	
	vi ret = countScans(ar,x,vals);
	FOR(i,q)cout << ret[i] << " ";cout << endl;
	return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 367 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 367 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 9054 ms 1144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 367 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -