結果

問題 No.1219 Mancala Combo
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2020-09-04 21:27:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 3,304 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 108,068 KB
実行使用メモリ 42,788 KB
最終ジャッジ日時 2023-08-17 14:54:05
合計ジャッジ時間 6,490 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,704 KB
testcase_01 AC 59 ms
22,812 KB
testcase_02 AC 58 ms
22,796 KB
testcase_03 AC 58 ms
18,800 KB
testcase_04 AC 65 ms
22,980 KB
testcase_05 AC 66 ms
22,904 KB
testcase_06 AC 58 ms
22,672 KB
testcase_07 AC 65 ms
23,192 KB
testcase_08 AC 65 ms
21,124 KB
testcase_09 AC 59 ms
22,808 KB
testcase_10 AC 58 ms
22,892 KB
testcase_11 AC 65 ms
21,024 KB
testcase_12 AC 58 ms
22,788 KB
testcase_13 AC 64 ms
18,888 KB
testcase_14 AC 59 ms
20,772 KB
testcase_15 AC 58 ms
20,628 KB
testcase_16 AC 58 ms
20,852 KB
testcase_17 AC 135 ms
37,088 KB
testcase_18 AC 180 ms
37,568 KB
testcase_19 AC 119 ms
31,472 KB
testcase_20 AC 183 ms
37,936 KB
testcase_21 AC 112 ms
28,600 KB
testcase_22 AC 165 ms
36,104 KB
testcase_23 AC 151 ms
38,728 KB
testcase_24 AC 145 ms
28,820 KB
testcase_25 AC 118 ms
31,204 KB
testcase_26 AC 180 ms
39,552 KB
testcase_27 AC 162 ms
39,912 KB
testcase_28 AC 226 ms
42,788 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 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.Ia;
		Bit2 bit=new Bit2(n+1);
		var ans="Yes";
		for(int i = 1;i<=n;i++) {bit.Ud(i,i,a[i-1]);}
		for(int i = n;i>0;i--) {
			var p=bit.Get(i,i);
			if(p==0){continue;}
			if(p%i!=0){
				ans="No";
				break;
			}
			bit.Ud(1,i,p/i);
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Bit2{
	private int n;
	private Bit bit1,bit2;
	public Bit2(int n){
		this.n=n;
		bit1=new Bit(n);
		bit2=new Bit(n);
	}
	public void Ud(int l,int r,long p){
		bit1.Ud(l,-p*(l-1));
		bit2.Ud(l,p);
		bit1.Ud(r+1,p*r);
		bit2.Ud(r+1,-p);
	}
	public long Get(int l,int r){return bit2.Get(r)*r+bit1.Get(r)-bit2.Get(l-1)*(l-1)-bit1.Get(l-1);}
	public class Bit{
		private int n;
		private long[] bit;
		public Bit(int n){
			this.n=n;
			bit=new long[n+1];
		}
		public void Ud(int a,long p){a++;while(a<=n){bit[a]+=p;a+=a&-a;}}
		public long Get(int n){
			n++;
			long a=0;
			while(n>0){a+=bit[n];n-=n&-n;}
			return a;
		}
		public void Clear(){bit=new long[n+1];}
	}
}
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