Submission #3441350


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int N,B[100010];
typedef long long ll;
ll merge_count(vector<ll> &a){
	int n = a.size();
	if(n<=1) return 0;
	ll cnt = 0;
	vector<ll> b(a.begin(),a.begin() + n/2);
	vector<ll> c(a.begin() + n/2, a.end());
	cnt += merge_count(b);
	cnt += merge_count(c);
	int ai = 0,bi = 0,ci = 0;
	while(ai<n){
		if(bi<b.size() && (ci == c.size() || b[bi] <= c[ci])){
			a[ai++] = b[bi++];
		}else{
			cnt += n/2 - bi;
			a[ai++] = c[ci++];
		}
	}
	return cnt;
}

int main(){
	cin >> N;
	vector<pair<int,int>> v;
	vector<ll> u(N);
	for(int i=0;i<N;i++){
		cin >> B[i];
		v.push_back({B[i],i});
	}
	sort(v.begin(),v.end());
	int l = 0,r = N-1;
	for(int i=0;i<v.size();i++){
		int j = v[i].second;
		if(j-l>r-j){
			u[j] = r;
			r--;
		}else{
			u[j] = l;
			l++;
		}
	}
	cout << merge_count(u) << endl;
}

Submission Info

Submission Time
Task C - 積み木
User idsigma
Language C++14 (GCC 5.4.1)
Score 0
Code Size 915 Byte
Status WA
Exec Time 55 ms
Memory 3700 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 0 / 30 0 / 70
Status
AC × 3
AC × 13
WA × 20
AC × 14
WA × 54
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
Subtask1 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 10_small_00.txt, 10_small_01.txt, 10_small_02.txt, 10_small_03.txt, 10_small_04.txt, 10_small_05.txt, 10_small_06.txt, 10_small_07.txt, 10_small_08.txt, 10_small_09.txt, 10_small_10.txt, 10_small_11.txt, 10_small_12.txt, 10_small_13.txt, 10_small_14.txt, 10_small_15.txt, 10_small_16.txt, 10_small_17.txt, 10_small_18.txt, 10_small_19.txt, 10_small_20.txt, 10_small_21.txt, 10_small_22.txt, 10_small_23.txt, 10_small_24.txt, 10_small_25.txt, 10_small_26.txt, 10_small_27.txt, 10_small_28.txt, 10_small_29.txt
Subtask2 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 10_small_00.txt, 10_small_01.txt, 10_small_02.txt, 10_small_03.txt, 10_small_04.txt, 10_small_05.txt, 10_small_06.txt, 10_small_07.txt, 10_small_08.txt, 10_small_09.txt, 10_small_10.txt, 10_small_11.txt, 10_small_12.txt, 10_small_13.txt, 10_small_14.txt, 10_small_15.txt, 10_small_16.txt, 10_small_17.txt, 10_small_18.txt, 10_small_19.txt, 10_small_20.txt, 10_small_21.txt, 10_small_22.txt, 10_small_23.txt, 10_small_24.txt, 10_small_25.txt, 10_small_26.txt, 10_small_27.txt, 10_small_28.txt, 10_small_29.txt, 20_rand_00.txt, 20_rand_01.txt, 20_rand_02.txt, 20_rand_03.txt, 20_rand_04.txt, 20_rand_05.txt, 20_rand_06.txt, 20_rand_07.txt, 20_rand_08.txt, 20_rand_09.txt, 20_rand_10.txt, 20_rand_11.txt, 20_rand_12.txt, 20_rand_13.txt, 20_rand_14.txt, 20_rand_15.txt, 20_rand_16.txt, 20_rand_17.txt, 20_rand_18.txt, 20_rand_19.txt, 20_rand_20.txt, 20_rand_21.txt, 20_rand_22.txt, 20_rand_23.txt, 20_rand_24.txt, 20_rand_25.txt, 20_rand_26.txt, 20_rand_27.txt, 20_rand_28.txt, 20_rand_29.txt, 30_max_0.txt, 30_max_1.txt, 30_max_2.txt, 30_max_3.txt, 30_max_4.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 256 KB
00_sample_01.txt AC 1 ms 256 KB
00_sample_02.txt AC 1 ms 256 KB
10_small_00.txt WA 1 ms 256 KB
10_small_01.txt AC 1 ms 256 KB
10_small_02.txt WA 1 ms 256 KB
10_small_03.txt WA 1 ms 256 KB
10_small_04.txt WA 1 ms 256 KB
10_small_05.txt WA 1 ms 256 KB
10_small_06.txt AC 1 ms 256 KB
10_small_07.txt WA 1 ms 256 KB
10_small_08.txt WA 1 ms 256 KB
10_small_09.txt WA 1 ms 256 KB
10_small_10.txt AC 1 ms 256 KB
10_small_11.txt WA 1 ms 256 KB
10_small_12.txt AC 1 ms 256 KB
10_small_13.txt WA 1 ms 256 KB
10_small_14.txt WA 1 ms 256 KB
10_small_15.txt AC 1 ms 256 KB
10_small_16.txt AC 1 ms 256 KB
10_small_17.txt AC 1 ms 256 KB
10_small_18.txt WA 1 ms 256 KB
10_small_19.txt AC 1 ms 256 KB
10_small_20.txt WA 1 ms 256 KB
10_small_21.txt AC 1 ms 256 KB
10_small_22.txt AC 1 ms 256 KB
10_small_23.txt WA 1 ms 256 KB
10_small_24.txt WA 1 ms 256 KB
10_small_25.txt WA 1 ms 256 KB
10_small_26.txt WA 1 ms 256 KB
10_small_27.txt WA 1 ms 256 KB
10_small_28.txt WA 1 ms 256 KB
10_small_29.txt WA 1 ms 256 KB
20_rand_00.txt WA 35 ms 2440 KB
20_rand_01.txt WA 5 ms 512 KB
20_rand_02.txt WA 10 ms 896 KB
20_rand_03.txt WA 17 ms 1296 KB
20_rand_04.txt WA 37 ms 2548 KB
20_rand_05.txt WA 50 ms 3316 KB
20_rand_06.txt WA 54 ms 3572 KB
20_rand_07.txt WA 38 ms 2548 KB
20_rand_08.txt WA 10 ms 896 KB
20_rand_09.txt WA 7 ms 640 KB
20_rand_10.txt WA 34 ms 2424 KB
20_rand_11.txt WA 16 ms 1304 KB
20_rand_12.txt WA 16 ms 1308 KB
20_rand_13.txt WA 21 ms 1528 KB
20_rand_14.txt WA 14 ms 1088 KB
20_rand_15.txt WA 4 ms 384 KB
20_rand_16.txt WA 24 ms 1784 KB
20_rand_17.txt WA 3 ms 384 KB
20_rand_18.txt WA 55 ms 3700 KB
20_rand_19.txt WA 11 ms 896 KB
20_rand_20.txt WA 8 ms 692 KB
20_rand_21.txt WA 35 ms 2452 KB
20_rand_22.txt WA 35 ms 2552 KB
20_rand_23.txt WA 53 ms 3572 KB
20_rand_24.txt WA 24 ms 1784 KB
20_rand_25.txt WA 26 ms 1912 KB
20_rand_26.txt WA 19 ms 1400 KB
20_rand_27.txt WA 20 ms 1528 KB
20_rand_28.txt WA 44 ms 2932 KB
20_rand_29.txt WA 7 ms 640 KB
30_max_0.txt AC 50 ms 3700 KB
30_max_1.txt WA 50 ms 3700 KB
30_max_2.txt WA 50 ms 3700 KB
30_max_3.txt WA 50 ms 3700 KB
30_max_4.txt WA 50 ms 3700 KB