結果
問題 | No.833 かっこいい電車 |
ユーザー |
![]() |
提出日時 | 2019-05-24 23:22:17 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,486 bytes |
コンパイル時間 | 2,067 ms |
コンパイル使用メモリ | 109,184 KB |
実行使用メモリ | 42,240 KB |
最終ジャッジ日時 | 2024-07-02 03:47:08 |
合計ジャッジ時間 | 9,059 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | TLE * 1 -- * 29 |
コンパイルメッセージ
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.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));}}