結果

問題 No.59 鉄道の旅
ユーザー ttkkggwwttkkggww
提出日時 2022-04-02 06:07:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 634 bytes
コンパイル時間 4,061 ms
コンパイル使用メモリ 260,656 KB
実行使用メモリ 15,576 KB
最終ジャッジ日時 2023-08-13 06:51:50
合計ジャッジ時間 5,103 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
15,204 KB
testcase_01 AC 8 ms
15,272 KB
testcase_02 AC 8 ms
15,164 KB
testcase_03 AC 8 ms
15,164 KB
testcase_04 AC 27 ms
15,576 KB
testcase_05 AC 8 ms
15,192 KB
testcase_06 AC 8 ms
15,168 KB
testcase_07 AC 8 ms
15,164 KB
testcase_08 AC 11 ms
15,220 KB
testcase_09 AC 11 ms
15,512 KB
testcase_10 AC 11 ms
15,156 KB
testcase_11 AC 9 ms
15,168 KB
testcase_12 AC 17 ms
15,484 KB
testcase_13 AC 24 ms
15,440 KB
testcase_14 AC 28 ms
15,520 KB
testcase_15 AC 8 ms
15,236 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