結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-28 23:32:33 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,827 bytes |
| コンパイル時間 | 962 ms |
| コンパイル使用メモリ | 111,820 KB |
| 実行使用メモリ | 28,672 KB |
| 最終ジャッジ日時 | 2024-11-24 06:28:34 |
| 合計ジャッジ時間 | 3,267 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 15 |
コンパイルメッセージ
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.Generic;
using System.Collections;
using System.Linq;
namespace contest
{
class contest
{
static void Main(string[] args)
{
//int n = int.Parse(Console.ReadLine());
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
//var n = int.Parse(Console.ReadLine());
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
long n = long.Parse(Console.ReadLine());
long score = 0;
var ch = new int[n.ToString().Length];
var memo = new int[10];
for(int i =0; i<n.ToString().Length; i++)
{
int tmp = (char)(n.ToString()[i]-'0');
memo[tmp]++;
ch[i] = memo[tmp];
}
var list = new List<int>();
var check = new bool[n.ToString().Length];
for(int i = 9; i>=0; i--)
{
if ( memo[i]==0) continue;
int tmp = 0;
int target = i;
if(target>0 )
{
var mm = new int[3];
tmp += target;
var arr = n.ToString().ToArray();
int ind = Array.IndexOf(arr,(char)(target+'0'));
if (check[ind]) continue;
mm[2] = ind;
//check[ind] = true;
for (int j = ind; j < arr.Length; j++)
{
int cur = arr[j]-'0';
if (!check[j]&&target!=cur && memo[cur] > 1 && ch[j] < memo[cur] && tmp.ToString().Length == 1)
{
tmp *= 10;
tmp += cur;
mm[0] = j;
//check[j] = true;
}
else if (!check[j]&& target!=cur&& tmp%10==cur&&memo[cur] > 1 && ch[j] <= memo[cur] && tmp.ToString().Length == 2)
{
tmp *= 10;
tmp += cur;
mm[1] = j;
//check[j] = true;
}
if (tmp.ToString().Length == 3) break;
}
if(tmp.ToString().Length==3)
{
list.Add(tmp);
check[mm[0]] = true;
check[mm[1]] = true;
check[mm[2]] = true;
}
}
}
Console.WriteLine(list.Sum());
//Console.WriteLine(score);
//Console.Read();
}
}
}