結果
| 問題 | No.871 かえるのうた |
| コンテスト | |
| ユーザー |
kekure
|
| 提出日時 | 2019-10-12 21:54:35 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,300 bytes |
| 記録 | |
| コンパイル時間 | 1,010 ms |
| コンパイル使用メモリ | 110,828 KB |
| 実行使用メモリ | 827,168 KB |
| 最終ジャッジ日時 | 2024-11-29 13:30:04 |
| 合計ジャッジ時間 | 12,255 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 TLE * 1 MLE * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FreeWorks
{
class Program
{
static void Main(string[] args)
{
string[] line = Console.ReadLine().Split(' ');
int n = int.Parse(line[0]);
int k = int.Parse(line[1]);
long[] X = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
long[] A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
bool[] check = new bool[n];
Queue<int> q = new Queue<int>();
q.Enqueue(k - 1);
int cnt = 0;
while (q.Count > 0)
{
int i = q.Dequeue();
if (check[i]) continue;
check[i] = true;
cnt++;
long rightRange = X[i] + A[i];
long leftRange = X[i] - A[i];
for (int x = i + 1; x < n && X[x] <= rightRange; x++)
{
q.Enqueue(x);
}
for (int x = i - 1; x >= 0 && leftRange <= X[x]; x--)
{
q.Enqueue(x);
}
}
Console.WriteLine(cnt);
}
}
}
kekure