답안 #166790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166790 2019-12-04T06:41:42 Z Dovran 돌 무게 재기 (IZhO11_stones) C++11
0 / 100
35 ms 1320 KB
#include <bits/stdc++.h>

#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define mid(a,b) (a+b)/2

using namespace std;

int n,T[N][3],T1[N][3],mx,mt,t,r;

void upd(int v,int pos,int l,int r,int nd){
	T[nd][1] += T[nd / 2][2];
	T1[nd][1] += T1[nd / 2][2];
	T[nd][2] += T[nd / 2][2];
	T1[nd][2] += T1[nd / 2][2];
	if(r <= pos){
		T[nd][1] += v;
		T[nd][2] += v;
		T1[nd][1] += v;
		T1[nd][2] += v;
		return;
	}
	if(l <= pos){
		upd(v,pos,l,mid(l,r),nd * 2);
		upd(v,pos,mid(l,r)+1,r,nd*2+1);
		T[nd][2] = 0;
		T1[nd][2] = 0;
		T[nd][1] = max(T[nd * 2][1],T[nd * 2 + 1][1]);
		T1[nd][1] = min(T1[nd * 2][1],T1[nd * 2 + 1][1]);
	}
}

int main()
{
	cin>>n;
	for(int i = 1;i <= n;i++){
		cin >> r >> t;
		if(r > mx){
			mx = r;
			mt = t;
		}
		if(t == 1)
			upd(-1,r,1,n,1);
		else upd(1,r,1,n,1);
		if(mt == 1)
			if(T[1][1] <= 0) cout << ">\n";
			else cout << "?\n";
		else {
			if(T1[1][1] >= 0) cout << "<\n";
			else cout << "?\n";
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 380 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 7 ms 504 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 35 ms 1320 KB Output is correct
11 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -