結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー 👑 kmjpkmjp
提出日時 2022-06-17 22:44:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 633 ms / 3,000 ms
コード長 1,905 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 198,388 KB
実行使用メモリ 41,472 KB
最終ジャッジ日時 2024-04-17 15:04:34
合計ジャッジ時間 16,940 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
17,792 KB
testcase_01 AC 14 ms
17,664 KB
testcase_02 AC 14 ms
17,920 KB
testcase_03 AC 347 ms
24,704 KB
testcase_04 AC 392 ms
25,984 KB
testcase_05 AC 158 ms
26,240 KB
testcase_06 AC 341 ms
30,464 KB
testcase_07 AC 339 ms
31,872 KB
testcase_08 AC 385 ms
26,752 KB
testcase_09 AC 380 ms
29,952 KB
testcase_10 AC 298 ms
28,928 KB
testcase_11 AC 141 ms
24,448 KB
testcase_12 AC 416 ms
28,544 KB
testcase_13 AC 309 ms
23,552 KB
testcase_14 AC 133 ms
26,624 KB
testcase_15 AC 281 ms
23,808 KB
testcase_16 AC 201 ms
28,672 KB
testcase_17 AC 523 ms
35,584 KB
testcase_18 AC 450 ms
33,792 KB
testcase_19 AC 480 ms
35,840 KB
testcase_20 AC 154 ms
21,120 KB
testcase_21 AC 116 ms
23,680 KB
testcase_22 AC 329 ms
24,832 KB
testcase_23 AC 162 ms
22,784 KB
testcase_24 AC 162 ms
23,808 KB
testcase_25 AC 514 ms
32,256 KB
testcase_26 AC 510 ms
33,792 KB
testcase_27 AC 84 ms
21,248 KB
testcase_28 AC 362 ms
24,832 KB
testcase_29 AC 509 ms
33,240 KB
testcase_30 AC 431 ms
30,184 KB
testcase_31 AC 374 ms
24,960 KB
testcase_32 AC 633 ms
39,168 KB
testcase_33 AC 590 ms
41,344 KB
testcase_34 AC 572 ms
41,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,K,Q;
int L[202020],R[202020],C[202020];
ll H[202020];

template<class V, int ME> class BIT {
public:
	V bit[1<<ME],val[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
	void set(int e,V v) { add(e,v-val[e]);}
	int lower_bound(V val) {
		V tv=0; int i,ent=0;
		for(i=ME-1;i>=0;i--) if(tv+bit[ent+(1<<i)-1]<val) tv+=bit[ent+(1<<i)-1],ent+=(1<<i);
		return ent;
	}
};
BIT<ll,20> bit;

vector<int> add[202020];
vector<int> del[202020];
vector<int> ev[202020];

int I[202020];
ll X[202020];
int ret[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>Q;
	FOR(i,K) {
		cin>>L[i]>>R[i]>>C[i]>>H[i];
		add[L[i]].push_back(i);
		del[R[i]].push_back(i);
	}
	FOR(i,Q) {
		cin>>I[i]>>X[i];
		ev[I[i]].push_back(i);
	}
	FOR(i,201000) {
		FORR(a,add[i]) bit.add(a,H[a]);
		FORR(e,ev[i]) {
			if(bit(1<<19)<X[e]) {
				ret[e]=-1;
			}
			else {
				x=bit.lower_bound(X[e]);
				ret[e]=C[x];
			}
		}
		
		FORR(a,del[i]) bit.add(a,-H[a]);
	}
	FOR(i,Q) cout<<ret[i]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0