結果
| 問題 | No.723 2つの数の和 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-10-18 00:00:15 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,309 bytes |
| コンパイル時間 | 949 ms |
| コンパイル使用メモリ | 112,272 KB |
| 実行使用メモリ | 37,080 KB |
| 最終ジャッジ日時 | 2024-10-12 18:58:39 |
| 合計ジャッジ時間 | 6,354 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 13 TLE * 1 -- * 1 |
コンパイルメッセージ
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.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
public class Program
{
static void Main(string[] args)
{
new Program().Main2(Console.In, Console.Out);
}
public void Main2(TextReader reader, TextWriter writer)
{
var sum = int.Parse(reader.ReadLine().Split()[1]);
var progression = reader.ReadLine().Split().Select(x => int.Parse(x)).ToList();
var combinationNum = 0;
progression.Sort();
int anotherCache = -1;
int countCache = -1;
foreach(var num in progression)
{
if (num >= sum) break;
var another = Math.Abs(sum - num);
if (another == anotherCache)
{
combinationNum += countCache;
break;
}
var anotherList = progression.FindAll(n => n == another);
combinationNum += anotherList.Count;
anotherCache = another;
countCache = anotherList.Count;
}
writer.WriteLine(combinationNum);
}
}
}