답안 #384069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
384069 2021-03-31T10:37:44 Z MODDI 코끼리 (Dancing Elephants) (IOI11_elephants) C++14
26 / 100
9000 ms 23944 KB
#include "elephants.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
#define MAX_N 1000000
#define MAX_M 1000000
using namespace std;
vi tree[4 * 150000], arr;
int Ltree[4 * 150000], l, n;
int calc(vi pos){
	int rez = 0, last = -1;
	for(int i = 0; i < (int)pos.size(); i++){
		if(pos[i] > last)
		{
			last = pos[i] + l;
			rez++;
		}
		else
			continue;
	}
	return rez;
}
void build(int node, int l, int r){
	if(l == r){
		vi nov;
		nov.pb(arr[l]);
		tree[node] = nov;
	}
	else{
		int mid = (l + r) / 2;
		build(node * 2, l, mid);
		build(node * 2 + 1, mid + 1, r);
		merge(tree[node * 2].begin(), tree[node * 2].end(), tree[node * 2 + 1].begin(), tree[node * 2  + 1].end(), back_inserter(tree[node]));
	}
}
void update1(int node, int l, int r, int pos, int val){
	if(l == r)
	{
		tree[node].clear();
		tree[node].pb(val);
		Ltree[node] = 1;
		return ;
	}
	int mid = (l + r) / 2;
	if(pos <= mid)
		update1(node * 2, l, mid, pos, val);
	else
		update1(node * 2 + 1, mid + 1, r, pos, val);
	tree[node].clear();
	merge(tree[node * 2].begin(), tree[node *2].end(), tree[node * 2 + 1].begin(), tree[node *2 + 1].end(), back_inserter(tree[node]));
}
void init(int N, int L, int X[])
{
	n = N;
	l = L;
	arr.resize(n);
	for(int i = 0; i < n; i++){
		arr[i] = X[i];
	}
	build(1, 0, n - 1);
}

int update(int i, int y)
{

	update1(1, 0, n - 1, i, y);
	return calc(tree[1]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 14444 KB Output is correct
2 Correct 11 ms 14444 KB Output is correct
3 Correct 11 ms 14444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 14444 KB Output is correct
2 Correct 11 ms 14444 KB Output is correct
3 Correct 11 ms 14444 KB Output is correct
4 Correct 11 ms 14464 KB Output is correct
5 Correct 12 ms 14444 KB Output is correct
6 Correct 10 ms 14444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 14444 KB Output is correct
2 Correct 11 ms 14444 KB Output is correct
3 Correct 11 ms 14444 KB Output is correct
4 Correct 11 ms 14464 KB Output is correct
5 Correct 12 ms 14444 KB Output is correct
6 Correct 10 ms 14444 KB Output is correct
7 Correct 6088 ms 16876 KB Output is correct
8 Correct 8675 ms 18040 KB Output is correct
9 Execution timed out 9072 ms 23944 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 14444 KB Output is correct
2 Correct 11 ms 14444 KB Output is correct
3 Correct 11 ms 14444 KB Output is correct
4 Correct 11 ms 14464 KB Output is correct
5 Correct 12 ms 14444 KB Output is correct
6 Correct 10 ms 14444 KB Output is correct
7 Correct 6088 ms 16876 KB Output is correct
8 Correct 8675 ms 18040 KB Output is correct
9 Execution timed out 9072 ms 23944 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 14444 KB Output is correct
2 Correct 11 ms 14444 KB Output is correct
3 Correct 11 ms 14444 KB Output is correct
4 Correct 11 ms 14464 KB Output is correct
5 Correct 12 ms 14444 KB Output is correct
6 Correct 10 ms 14444 KB Output is correct
7 Correct 6088 ms 16876 KB Output is correct
8 Correct 8675 ms 18040 KB Output is correct
9 Execution timed out 9072 ms 23944 KB Time limit exceeded
10 Halted 0 ms 0 KB -