結果
| 問題 |
No.664 超能力者Aと株価予測
|
| コンテスト | |
| ユーザー |
バカらっく
|
| 提出日時 | 2018-03-09 23:58:28 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,205 bytes |
| コンパイル時間 | 1,046 ms |
| コンパイル使用メモリ | 113,692 KB |
| 実行使用メモリ | 41,344 KB |
| 最終ジャッジ日時 | 2024-10-10 21:12:43 |
| 合計ジャッジ時間 | 7,043 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 2 TLE * 1 -- * 6 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program
{
public void Proc()
{
int[] inpt = Reader.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
int openTime = inpt[0];
int maxCount = inpt[1];
long syojikin = inpt[2];
Kabuka = new int[openTime + 1];
State st = State.Even;
for (int i = 0; i <= openTime; i++) {
Kabuka[i] = int.Parse(Reader.ReadLine());
if(i>0) {
if(Kabuka[i]>Kabuka[i-1]) {
if (st == State.Even)
{
Tani.Add(0);
} else if(st == State.Kudari) {
Tani.Add(i - 1);
}
st = State.Nobori;
} else if(Kabuka[i]<Kabuka[i-1]) {
if(st == State.Even) {
Yama.Add(0);
} else if(st == State.Nobori) {
Yama.Add(i - 1);
}
st = State.Kudari;
}
if(i == openTime) {
if(st == State.Nobori) {
Yama.Add(i);
} else if(st == State.Kudari) {
Tani.Add(i);
}
}
}
}
long ans = GetAns(0, syojikin, maxCount);
Console.WriteLine(ans);
}
private long GetAns(int idx, long money, int remain) {
long ans = money;
if(remain <= 0) {
return money;
}
if(idx >=Kabuka.Length) {
return money;
}
if(!Tani.Any(a=>a>=idx)) {
return money;
}
int kai = Tani.First(a => a >= idx);
if(!Yama.Any(a=>a>kai)) {
return money;
}
int uri = Yama.First(a => a > kai);
long kabu = money / Kabuka[kai];
long zan = money - (kabu * Kabuka[kai]);
zan += Kabuka[uri] * kabu;
ans = Math.Max(ans, GetAns(uri + 1, zan, remain - 1));
ans = Math.Max(ans, GetAns(kai + 1, money, remain));
return ans;
}
int[] Kabuka;
private List<int> Yama = new List<int>();
private List<int> Tani = new List<int>();
private enum State {
Nobori,
Kudari,
Even,
}
public class Reader
{
static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine()
{
if (IsDebug)
{
if (sr == null)
{
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
}
else
{
return Console.ReadLine();
}
}
private static string InputText = @"
21 5 3000
150
144
133
130
127
129
138
142
131
131
126
126
133
135
121
115
122
130
124
110
138
134
";
}
public static void Main(string[] args)
{
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
バカらっく