結果
問題 | No.871 かえるのうた |
ユーザー | kenta255 |
提出日時 | 2019-08-30 22:09:06 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 332 ms / 2,000 ms |
コード長 | 1,523 bytes |
コンパイル時間 | 3,203 ms |
コンパイル使用メモリ | 219,412 KB |
実行使用メモリ | 15,616 KB |
最終ジャッジ日時 | 2023-08-20 09:19:26 |
合計ジャッジ時間 | 8,958 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 4 ms
4,376 KB |
testcase_09 | AC | 5 ms
4,376 KB |
testcase_10 | AC | 3 ms
4,376 KB |
testcase_11 | AC | 3 ms
4,376 KB |
testcase_12 | AC | 23 ms
5,488 KB |
testcase_13 | AC | 6 ms
4,376 KB |
testcase_14 | AC | 169 ms
15,616 KB |
testcase_15 | AC | 169 ms
15,332 KB |
testcase_16 | AC | 203 ms
15,592 KB |
testcase_17 | AC | 155 ms
14,628 KB |
testcase_18 | AC | 27 ms
5,672 KB |
testcase_19 | AC | 173 ms
15,380 KB |
testcase_20 | AC | 14 ms
4,428 KB |
testcase_21 | AC | 68 ms
7,464 KB |
testcase_22 | AC | 2 ms
4,380 KB |
testcase_23 | AC | 2 ms
4,380 KB |
testcase_24 | AC | 2 ms
4,380 KB |
testcase_25 | AC | 4 ms
4,380 KB |
testcase_26 | AC | 13 ms
4,660 KB |
testcase_27 | AC | 19 ms
5,240 KB |
testcase_28 | AC | 2 ms
4,376 KB |
testcase_29 | AC | 76 ms
11,112 KB |
testcase_30 | AC | 128 ms
12,340 KB |
testcase_31 | AC | 4 ms
4,376 KB |
testcase_32 | AC | 109 ms
11,108 KB |
testcase_33 | AC | 149 ms
15,412 KB |
testcase_34 | AC | 36 ms
6,480 KB |
testcase_35 | AC | 89 ms
10,644 KB |
testcase_36 | AC | 124 ms
13,308 KB |
testcase_37 | AC | 77 ms
8,040 KB |
testcase_38 | AC | 252 ms
14,820 KB |
testcase_39 | AC | 332 ms
14,076 KB |
testcase_40 | AC | 90 ms
11,324 KB |
testcase_41 | AC | 2 ms
4,380 KB |
testcase_42 | AC | 86 ms
12,988 KB |
testcase_43 | AC | 1 ms
4,376 KB |
testcase_44 | AC | 2 ms
4,384 KB |
testcase_45 | AC | 4 ms
4,376 KB |
testcase_46 | AC | 2 ms
4,376 KB |
testcase_47 | AC | 2 ms
4,376 KB |
testcase_48 | AC | 2 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define P pair<ll,ll> #define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I) #define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I) #define TO(x,t,f) ((x)?(t):(f)) #define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9 #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v x is sorted #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v x is sorted #define NUM(x,v) (POSU(x,v)-POSL(x,v)) //x is sorted #define REV(x) (reverse(x.begin(),x.end())) //reverse ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);} ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);} #define NEXTP(x) next_permutation(x.begin(),x.end()) const ll INF=ll(1e18)+ll(7); const ll MOD=1000000007LL; #define out(a) cout<<fixed<<setprecision((a)) int main(){ ll N,K; cin >> N >> K; K--; ll ans = 0; set<ll> setX; map<ll,ll> indexX; vector<ll> A(N),X(N); FOR(i,0,N){ cin >> X[i]; if(i!=K)setX.insert(X[i]); indexX[X[i]] = i; } FOR(i,0,N)cin >> A[i]; queue<ll> nex; vector<bool> did(N,0); nex.push(K); did[K] = true; while(nex.size()){ ans++; ll nowi = nex.front(); nex.pop(); ll nowX = X[nowi]; ll nowA = A[nowi]; vector<ll> usedX; auto it = setX.upper_bound(nowX-nowA-1LL); auto la = setX.upper_bound(nowX+nowA); while(it != la){ ll XXX = *it; nex.push(indexX[XXX]); usedX.push_back(XXX); ++it; } for(auto xxx:usedX){ setX.erase(xxx); } } cout << ans << endl; }