結果
| 問題 |
No.59 鉄道の旅
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-02 06:07:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 5,000 ms |
| コード長 | 634 bytes |
| コンパイル時間 | 3,869 ms |
| コンパイル使用メモリ | 253,240 KB |
| 最終ジャッジ日時 | 2025-01-28 14:31:36 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 12 |
ソースコード
#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();
}