結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-04-29 04:37:44 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,345 bytes |
| コンパイル時間 | 1,153 ms |
| コンパイル使用メモリ | 106,112 KB |
| 実行使用メモリ | 21,736 KB |
| 最終ジャッジ日時 | 2024-09-13 19:04:12 |
| 合計ジャッジ時間 | 9,717 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 7 |
コンパイルメッセージ
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;
public class Program
{
public static void Main(string[] args)
{
new Magatro().Solve();
}
}
class Magatro
{
private int N, D, K;
private int[] x;
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];
for (int i = 0; i < N; i++)
{
x[i] = int.Parse(Console.ReadLine());
}
}
public void Solve()
{
Scan();
int[] B = new int[(N + 1000 - 1) / 1000];
int[] index = new int[(N + 1000 - 1) / 1000];
int maxleft = -1;
int maxright = -1;
for (int i = 0; i < N; i++)
{
if (B[i / 1000] < x[i])
{
B[i / 1000] = x[i];
index[i / 1000] = i;
}
}
int max = 0;
for (int i = 0; i < N - 1; i++)
{
int right = Math.Min(i + D, N - 1);
int bleft = i / 1000;
int bright = right / 1000;
int m = 0;
int rightindex = -1;
for (int j = bleft; j < bright; j++)
{
if (m < B[j])
{
m = B[j];
rightindex = index[j];
}
}
for (int j = i; j <= right && j % 1000 < 999; j++)
{
if (m < x[j])
{
m = x[j];
rightindex = j;
}
}
for (int j = right; j >= i && j % 1000 < 999; j--)
{
if (m < x[j])
{
m = x[j];
rightindex = j;
}
}
if (max < m - x[i])
{
maxleft = i;
maxright = rightindex;
max = m - x[i];
}
}
Console.WriteLine((long)K * max);
if (max == 0)
{
return;
}
Console.WriteLine($"{maxleft} {maxright}");
}
}
mban