結果

問題 No.59 鉄道の旅
ユーザー ttkkggwwttkkggww
提出日時 2022-04-02 06:07:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 634 bytes
コンパイル時間 3,731 ms
コンパイル使用メモリ 263,584 KB
実行使用メモリ 15,728 KB
最終ジャッジ日時 2024-05-01 00:46:19
合計ジャッジ時間 4,791 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
15,216 KB
testcase_01 AC 6 ms
15,276 KB
testcase_02 AC 6 ms
15,392 KB
testcase_03 AC 6 ms
15,284 KB
testcase_04 AC 21 ms
15,536 KB
testcase_05 AC 6 ms
15,356 KB
testcase_06 AC 6 ms
15,380 KB
testcase_07 AC 5 ms
15,328 KB
testcase_08 AC 8 ms
15,332 KB
testcase_09 AC 7 ms
15,384 KB
testcase_10 AC 8 ms
15,316 KB
testcase_11 AC 6 ms
15,316 KB
testcase_12 AC 13 ms
15,580 KB
testcase_13 AC 19 ms
15,692 KB
testcase_14 AC 23 ms
15,728 KB
testcase_15 AC 5 ms
15,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int n,k;
vector<int> w;

int op(int l,int r){
	return l+r;
}

int e(){
	return 0;
}


void solve(){
	segtree<int,op,e> SEG(1000001);
	for(int i = 0;i<n;i++){
		if(w[i]<0){
			if(SEG.get(-w[i])<=0){
			}else{
				SEG.set(-w[i],SEG.get(-w[i])-1);
			}
		}else{
			if(SEG.prod(w[i],1000001)>=k){
			}else{
				SEG.set(w[i],SEG.get(w[i])+1);
			}
		}
	}
	cout<<SEG.all_prod()<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	w = vector<int>(n);
	for(auto &i:w)cin >> i;
	solve();
}
0