結果
| 問題 |
No.935 う し た ぷ に き あ く ん 笑 ビ - ム
|
| コンテスト | |
| ユーザー |
tsushima
|
| 提出日時 | 2019-11-30 10:05:55 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,402 bytes |
| コンパイル時間 | 994 ms |
| コンパイル使用メモリ | 115,068 KB |
| 実行使用メモリ | 30,216 KB |
| 最終ジャッジ日時 | 2024-11-21 01:00:47 |
| 合計ジャッジ時間 | 8,389 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 WA * 46 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
using System.Collections.Generic;
namespace Algorithm
{
class Program
{
static void Main(string[] args)
{
var N = int.Parse(Console.ReadLine());
var S = Console.ReadLine();
var A = Console.ReadLine().Split().Select(int.Parse).OrderBy(z => z).ToArray();
var Q = int.Parse(Console.ReadLine());
var K = Console.ReadLine().Split().Select(long.Parse).ToArray();
var acum = new long[N + 1];
var count = new int[N + 1];
for (var i = 0; i < N; i++)
{
acum[i + 1] = acum[i] + A[i];
count[i + 1] = count[i] + (S[i] == 'E' ? 1 : 0);
}
for (var i = 0; i < Q; i++)
{
var ans = 0;
for (var j = 0; j <= N; j++)
{
var ok = j;
var ng = N + 1;
while (ng - ok > 1)
{
var med = (ng + ok) / 2;
if (acum[med] - acum[j] <= K[i])
ok = med;
else
ng = med;
}
ans = Math.Max(ans, count[ok] - count[j]);
}
Console.WriteLine(ans);
}
}
}
}
tsushima