結果
問題 | No.151 セグメントフィッシング |
ユーザー | tassi_2012 |
提出日時 | 2015-02-15 23:45:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,380 bytes |
コンパイル時間 | 2,349 ms |
コンパイル使用メモリ | 107,248 KB |
実行使用メモリ | 30,548 KB |
最終ジャッジ日時 | 2023-09-06 01:28:26 |
合計ジャッジ時間 | 59,275 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 61 ms
20,932 KB |
testcase_01 | AC | 60 ms
18,804 KB |
testcase_02 | AC | 63 ms
20,800 KB |
testcase_03 | AC | 61 ms
22,688 KB |
testcase_04 | AC | 61 ms
20,728 KB |
testcase_05 | AC | 62 ms
20,736 KB |
testcase_06 | AC | 61 ms
20,680 KB |
testcase_07 | AC | 62 ms
20,808 KB |
testcase_08 | AC | 356 ms
20,792 KB |
testcase_09 | AC | 344 ms
22,936 KB |
testcase_10 | AC | 353 ms
20,716 KB |
testcase_11 | AC | 353 ms
20,660 KB |
testcase_12 | TLE | - |
testcase_13 | AC | 4,928 ms
27,596 KB |
testcase_14 | AC | 4,994 ms
27,632 KB |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | AC | 1,209 ms
27,004 KB |
testcase_20 | AC | 1,246 ms
26,860 KB |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | AC | 3,815 ms
25,484 KB |
コンパイルメッセージ
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.Generic; class program { public static void Main() { var str = Console.ReadLine().Split(' '); var N = int.Parse(str[0]); var Q = int.Parse(str[1]); Pool pool = new Pool(N); for (int i = 0; i < Q; i++) { str = Console.ReadLine().Split(' '); string x = str[0]; int y = int.Parse(str[1]); long z = long.Parse(str[2]); if (x.Equals("C")) { Console.WriteLine(pool.outputSum(y, (int)z)); } else { pool.add(x, y, z); } pool.next(); } } } public class Pool { private int length; private List<Fish> flist; public Pool(int N) { this.length = N; this.flist = new List<Fish>(); } public void add(string direction, int position, long num) { flist.Add(new Fish(direction, position, num, this.length)); } public void next() { foreach(Fish fish in flist){ fish.next(); } } public long outputSum(int left, int right) { long sum = 0; foreach (Fish fish in flist) { int posi = fish.getPosition(); if (left <= posi && posi < right) { sum += fish.getNum(); } } return sum; } } public class Fish { private string direction; private int position; private long num; private int length; public Fish(string direction, int position, long num, int length) { this.direction = direction; this.position = position; this.num = num; this.length = length; } public void next() { if (direction.Equals("R")) { if (position + 1 == length) { direction = "L"; } else { position++; } } else { if (position - 1 < 0) { direction = "R"; } else { position--; } } } public long getNum() { return this.num; } public int getPosition() { return this.position; } }