結果
問題 |
No.871 かえるのうた
|
ユーザー |
|
提出日時 | 2019-08-30 21:33:03 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 937 bytes |
コンパイル時間 | 961 ms |
コンパイル使用メモリ | 128,548 KB |
実行使用メモリ | 13,916 KB |
最終ジャッジ日時 | 2024-06-22 02:24:31 |
合計ジャッジ時間 | 3,579 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 WA * 8 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; void main() { auto s = readln.split.map!(to!int); auto n = s[0]; auto k = s[1] - 1; auto X = readln.split.map!(to!long).array; auto A = readln.split.map!(to!long).array; auto B = n.iota.map!(i => tuple(X[i], A[i], i)).array; B.sort!"a[0] < b[0]"; int idx = -1; foreach (i; 0..n) if (B[i][2] == k) idx = i; int ans = 1; long mx = B[idx][0] + B[idx][1]; foreach (i; idx+1..n) { if (B[i][0] <= mx) { ans += 1; mx = max(mx, B[i][0] + B[i][1]); } } mx = B[idx][0] - B[idx][1]; foreach_reverse (i; 0..idx) { if (B[i][0] >= mx) { ans += 1; mx = min(mx, B[i][0] - B[i][1]); } } ans.writeln; }