結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-05-09 21:11:21 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,227 bytes |
| コンパイル時間 | 3,667 ms |
| コンパイル使用メモリ | 104,832 KB |
| 実行使用メモリ | 25,816 KB |
| 最終ジャッジ日時 | 2024-09-14 20:06:24 |
| 合計ジャッジ時間 | 5,914 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 1 TLE * 1 -- * 33 |
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
class Program
{
static void Main(string[] args)
{
new Magatro().Solve();
}
}
public class Magatro
{
private int N, D, K;
private int[] X;
private int[] Table;
private int[] Index;
private const int T = 1000;
private void Scan()
{
string[] line = Console.ReadLine().Split(' ');
N = int.Parse(line[0]);
D = int.Parse(line[1]);
K = int.Parse(line[2]);
X = new int[N];
Table = new int[(N + T - 1) / T];
Index = new int[(N + T - 1) / T];
for (int i = 0; i < N; i++)
{
X[i] = int.Parse(Console.ReadLine());
if (Table[i / T] < X[i])
{
Table[i / T] = X[i];
Index[i / T] = i;
}
}
}
public void Solve()
{
Scan();
int ans = 0;
int ansL = -1, ansR = -1;
for (int i = 0; i < N - 1; i++)
{
int right = Math.Min(i + D, N - 1);
int max = 0;
int r = -1;
for (int j = i + 1; j <= right && j % T <= T - 1; j++)
{
if (max < X[j])
{
max = X[j];
r = j;
}
}
for (int j = i / T + 1; j < right / T; j++)
{
if (max < Table[j])
{
max = Table[j];
r = Index[j];
}
}
for (int j = right; j >= i && j % T != T - 1; j--)
{
if (max <= X[j])
{
max = X[j];
r = j;
}
}
if (ans < max - X[i])
{
ans = max - X[i];
ansL = i;
ansR = r;
}
}
Console.WriteLine((long)ans * K);
if(ans == 0)
{
return;
}
Console.WriteLine($"{ansL} {ansR}");
}
}
mban