Submission #102443

# Submission time Handle Problem Language Result Execution time Memory
102443 2019-03-25T02:54:02 Z IOrtroiii Bubble Sort 2 (JOI18_bubblesort2) C++14
38 / 100
9000 ms 2740 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 500500;
const int MAGIC = 1616;

struct SegmentTree {
	vector<int> lz;
	vector<int> cnt;
	vector<int> val;
	void resize(int n) {
		lz.resize((n << 2) + 5);
		cnt.resize((n << 2) + 5);
		val.resize((n << 2) + 5);
	}
	void pull(int v) {
		cnt[v] = cnt[v << 1] + cnt[v << 1 | 1];
		val[v] = max(val[v << 1], val[v << 1 | 1]);
	}
	void push(int v,int l,int r) {
		if (lz[v]) {
			val[v] += lz[v];
			if (l < r) {
				lz[v << 1] += lz[v];
				lz[v << 1 | 1] += lz[v];
			}
			lz[v] = 0;
		}
	}
	void addVal(int v,int l,int r,int L,int R) {
		
	}
};

vector<int> countScans(vector<int> a,vector<int> x,vector<int> y) {
	// brute
	int n = a.size(), q = x.size();
	vector<int> f(n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < i; ++j) {
			f[i] += a[j] > a[i];
		} 
	}
	vector<int> ans;
	for (int i = 0; i < q; ++i) {
		// delval
		for (int j = x[i] + 1; j < n; ++j) {
			if (a[j] < a[x[i]]) {
				f[j]--;
			}
		}	
		a[x[i]] = y[i];
		for (int j = x[i] + 1; j < n; ++j) {
			if (a[j] < a[x[i]]) {
				f[j]++;
			}
		}
		f[x[i]] = 0;
		for (int j = 0; j < x[i]; ++j) {
			if (a[j] > a[x[i]]) {
				f[x[i]]++;
			}
		}
		ans.push_back(*max_element(f.begin(), f.end()));
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 34 ms 416 KB Output is correct
4 Correct 35 ms 476 KB Output is correct
5 Correct 32 ms 384 KB Output is correct
6 Correct 24 ms 464 KB Output is correct
7 Correct 26 ms 384 KB Output is correct
8 Correct 29 ms 512 KB Output is correct
9 Correct 32 ms 504 KB Output is correct
10 Correct 26 ms 384 KB Output is correct
11 Correct 27 ms 504 KB Output is correct
12 Correct 28 ms 504 KB Output is correct
13 Correct 25 ms 476 KB Output is correct
14 Correct 30 ms 384 KB Output is correct
15 Correct 25 ms 428 KB Output is correct
16 Correct 26 ms 512 KB Output is correct
17 Correct 22 ms 384 KB Output is correct
18 Correct 28 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 34 ms 416 KB Output is correct
4 Correct 35 ms 476 KB Output is correct
5 Correct 32 ms 384 KB Output is correct
6 Correct 24 ms 464 KB Output is correct
7 Correct 26 ms 384 KB Output is correct
8 Correct 29 ms 512 KB Output is correct
9 Correct 32 ms 504 KB Output is correct
10 Correct 26 ms 384 KB Output is correct
11 Correct 27 ms 504 KB Output is correct
12 Correct 28 ms 504 KB Output is correct
13 Correct 25 ms 476 KB Output is correct
14 Correct 30 ms 384 KB Output is correct
15 Correct 25 ms 428 KB Output is correct
16 Correct 26 ms 512 KB Output is correct
17 Correct 22 ms 384 KB Output is correct
18 Correct 28 ms 452 KB Output is correct
19 Correct 416 ms 900 KB Output is correct
20 Correct 494 ms 944 KB Output is correct
21 Correct 390 ms 1016 KB Output is correct
22 Correct 424 ms 1016 KB Output is correct
23 Correct 354 ms 820 KB Output is correct
24 Correct 350 ms 920 KB Output is correct
25 Correct 348 ms 888 KB Output is correct
26 Correct 355 ms 888 KB Output is correct
27 Correct 365 ms 1016 KB Output is correct
28 Correct 338 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 796 ms 988 KB Output is correct
2 Correct 8119 ms 1952 KB Output is correct
3 Execution timed out 9036 ms 2740 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 34 ms 416 KB Output is correct
4 Correct 35 ms 476 KB Output is correct
5 Correct 32 ms 384 KB Output is correct
6 Correct 24 ms 464 KB Output is correct
7 Correct 26 ms 384 KB Output is correct
8 Correct 29 ms 512 KB Output is correct
9 Correct 32 ms 504 KB Output is correct
10 Correct 26 ms 384 KB Output is correct
11 Correct 27 ms 504 KB Output is correct
12 Correct 28 ms 504 KB Output is correct
13 Correct 25 ms 476 KB Output is correct
14 Correct 30 ms 384 KB Output is correct
15 Correct 25 ms 428 KB Output is correct
16 Correct 26 ms 512 KB Output is correct
17 Correct 22 ms 384 KB Output is correct
18 Correct 28 ms 452 KB Output is correct
19 Correct 416 ms 900 KB Output is correct
20 Correct 494 ms 944 KB Output is correct
21 Correct 390 ms 1016 KB Output is correct
22 Correct 424 ms 1016 KB Output is correct
23 Correct 354 ms 820 KB Output is correct
24 Correct 350 ms 920 KB Output is correct
25 Correct 348 ms 888 KB Output is correct
26 Correct 355 ms 888 KB Output is correct
27 Correct 365 ms 1016 KB Output is correct
28 Correct 338 ms 864 KB Output is correct
29 Correct 796 ms 988 KB Output is correct
30 Correct 8119 ms 1952 KB Output is correct
31 Execution timed out 9036 ms 2740 KB Time limit exceeded
32 Halted 0 ms 0 KB -