結果
問題 |
No.935 う し た ぷ に き あ く ん 笑 ビ - ム
|
ユーザー |
![]() |
提出日時 | 2020-02-10 09:23:37 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,945 bytes |
コンパイル時間 | 815 ms |
コンパイル使用メモリ | 108,128 KB |
実行使用メモリ | 33,656 KB |
最終ジャッジ日時 | 2024-10-01 06:13:52 |
合計ジャッジ時間 | 5,785 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | AC * 17 TLE * 1 -- * 40 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; namespace yukicode { class No935 { static void Main(string[] args) { int targetNum = 0; int attackNum = 0; int retOne = 0; int retStart = 0; int retEnd = 0; int output = 0; int power = 0; string input; string sort; input = Console.ReadLine(); targetNum = int.Parse(input); sort = Console.ReadLine(); input = Console.ReadLine(); string[] str1 = input.Split(" "); int[] hp = new int[targetNum]; for(int i=0; i < targetNum; i++) { hp[i] = int.Parse(str1[i]); } input = Console.ReadLine(); attackNum = int.Parse(input); input = Console.ReadLine(); string[] str2 = input.Split(" "); for (int i = 0; i < attackNum; i++) { power = int.Parse(str2[i]); retOne = AttackOne(sort, hp, power); if(1 == retOne) { retStart = AttackStart(sort, hp, power); retEnd = AttackEnd(sort, hp, power); if(retStart >= retEnd) { output = retStart; } else { output = retEnd; } } else { output = retOne; } Console.WriteLine(output); } return; } static private int AttackOne(string sort, int[] hp, int power) { int ret = 0; for(int i = 0; i < hp.Length; i++) { if('E' == sort[i]) { if(hp[i] <= power) { ret = 1; break; } } } return ret; } static private int AttackStart(string sort, int[] hp, int power) { int ret = 0; int tempMax = 0; int tempPower = 0; for(int i = 0; i < hp.Length; i++) { tempMax = 0; tempPower = power; for (int j = i; j < hp.Length; j++) { if (hp[j] <= tempPower) { tempPower = tempPower - hp[j]; if ('E' == sort[j]) { tempMax++; } } else { break; } } if(ret < tempMax) { ret = tempMax; } } return ret; } static private int AttackEnd(string sort, int[] hp, int power) { int ret = 0; int tempMax = 0; int tempPower = 0; for (int i = hp.Length -1; i >= 0; i--) { tempMax = 0; tempPower = power; for (int j = 0; j >= 0; j--) { if (hp[i] <= tempPower) { tempPower = tempPower - hp[i]; if ('E' == sort[i]) { tempMax++; } } else { break; } } if (ret < tempMax) { ret = tempMax; } } return ret; } } }