結果

問題 No.1268 Fruit Rush 2
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2020-10-23 23:58:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 2,753 bytes
コンパイル時間 2,304 ms
コンパイル使用メモリ 108,228 KB
実行使用メモリ 58,108 KB
最終ジャッジ日時 2023-09-28 19:17:57
合計ジャッジ時間 9,973 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
20,860 KB
testcase_01 AC 68 ms
20,840 KB
testcase_02 AC 67 ms
20,864 KB
testcase_03 AC 65 ms
20,984 KB
testcase_04 AC 66 ms
20,840 KB
testcase_05 AC 64 ms
20,840 KB
testcase_06 AC 65 ms
20,832 KB
testcase_07 AC 65 ms
20,784 KB
testcase_08 AC 65 ms
22,760 KB
testcase_09 AC 67 ms
20,908 KB
testcase_10 AC 66 ms
20,832 KB
testcase_11 AC 67 ms
22,812 KB
testcase_12 AC 67 ms
22,876 KB
testcase_13 AC 66 ms
20,880 KB
testcase_14 AC 67 ms
20,940 KB
testcase_15 AC 67 ms
20,936 KB
testcase_16 AC 204 ms
42,736 KB
testcase_17 AC 186 ms
44,276 KB
testcase_18 AC 192 ms
43,532 KB
testcase_19 AC 194 ms
46,968 KB
testcase_20 AC 191 ms
46,696 KB
testcase_21 AC 192 ms
46,236 KB
testcase_22 AC 206 ms
42,828 KB
testcase_23 AC 207 ms
42,608 KB
testcase_24 AC 195 ms
46,876 KB
testcase_25 AC 190 ms
42,528 KB
testcase_26 AC 276 ms
57,076 KB
testcase_27 AC 274 ms
57,156 KB
testcase_28 AC 275 ms
58,108 KB
testcase_29 AC 278 ms
57,208 KB
testcase_30 AC 275 ms
54,404 KB
testcase_31 AC 247 ms
48,208 KB
testcase_32 AC 246 ms
46,168 KB
testcase_33 AC 279 ms
52,428 KB
testcase_34 AC 218 ms
44,796 KB
testcase_35 AC 277 ms
52,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Diagnostics;
//using nint=System.Int32;
static class Program{
	const int mod=(int)1e9+7;
	//const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.La;
		Array.Sort(a);
		var hs=new Dictionary<long,int>();
		long ans=0;
		for(int i = 0;i<n;i++) {
			if(hs.ContainsKey(a[i]-1)){
				hs.Add(a[i],1);
			}
			else{
				hs.Add(a[i],0);
			}
			if(hs.ContainsKey(a[i]-2)){
				hs[a[i]]+=hs[a[i]-2];
			}
			ans+=hs[a[i]]+1;
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}
0