結果

問題 No.833 かっこいい電車
ユーザー kuuso1kuuso1
提出日時 2019-05-24 23:22:17
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,486 bytes
コンパイル時間 4,264 ms
コンパイル使用メモリ 108,848 KB
実行使用メモリ 45,504 KB
最終ジャッジ日時 2023-09-14 20:57:04
合計ジャッジ時間 11,072 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int M = 334;
		int P = 300;
		long[] A = new long[M * P];
		for(int i=0;i<N;i++) A[i] = AA[i];
		
		long[] pSum = new long[M];
		bool[] pJoin = new bool[M];
		bool[] Join = new bool[M * P];
		for(int q = 0; q < Q; q++){
			
			int x = Query[q][1];
			int t = Query[q][0];
			switch(t){
				
				case 1:{
					Join[x] = true;
					
					int p = x / P;
					bool chk = true;
					long sum = A[p * P];
					for(int j=0;j<P-1;j++){
						chk &= Join[p * P + j];
						sum += A[p * P + j + 1];
					}
					if(chk){
						pJoin[p] = true;
						pSum[p] = sum;
					}
				} break;
				
				case 2: {
					Join[x] = false;
					int p = x / P;
					pJoin[p] = false;
					
				} break;
				
				case 3: {
					A[x]++;
					int p = x / P;
					if(pJoin[p]){
						pSum[p]++;
					}
				} break;
				
				case 4: {
					
					long sum = 0;
					for(int j=x;j<N;j++){
						if(j % P == 0 && pJoin[j / P]){
							sum += pSum[j / P];
							j += P - 1;
							if(Join[j]) continue;
							break;
						} else {
							sum += A[j];
							if(Join[j]){
								continue;
							} else {
								break;
							}
						}
					}
					
					for(int j=x-1;j>=0;j--){
						if(!Join[j]) break;
						if(j % P == P - 1 && pJoin[j / P]){
							sum += pSum[j / P];
							j -= P;
						} else {
							sum += A[j];
						}
					}
					
					Console.WriteLine(sum);
				} break;
				
				
			}
			//Console.WriteLine("{0} : done",t);
			
		}
	}
	int N;
	int Q;
	long[] AA;
	int[][] Query;
	public Sol(){
		var d = ria();
		N = d[0]; Q = d[1];
		AA = rla();
		Query = new int[Q][];
		for(int i=0;i<Q;i++) {
			Query[i] = ria();
			Query[i][1]--;
		}
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0