Submission #172311


Source Code Expand

Copy
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
	static void Main(string[] args) {
		new Program().solve();
	}

	Action<Object> PUTS = str => Console.WriteLine(str);
	Action<int[,]> LIST = (array2D) => {
		for (int i = 0; i < array2D.GetLength(0); i++) {
			for (int j = 0; j < array2D.GetLength(1); j++) Console.Write("{0,-3} ", array2D[i, j]);
			Console.WriteLine();
		}
	};
	Action<int, Action<int>> REP = (n, action) => { for (int i = 0; i < n; i++) action(i); };
	Action<int, int, Action<int>> FOR = (a, b, action) => { for (int i = a; i < b; i++) action(i); };
	Action<int, int, Action<int, int>> NEST = (row, col, action) => {
		for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) action(i, j);
	};

	public void solve() {

		Scanner cin = new Scanner();
		int n = cin.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = cin.nextInt();

		List<int> list = new List<int>();
		int start = 0;
		int end = 0;

		for (int i = 0; i < n; i++) {
			if (a[i] == -1) {
				int j = i + 1;
				while (a[j] != -1) j++;
				end = a[j];

				if (j == i + 1) {
						// すぐ次
						list.Add((end - start + 1) % 1000000007);
					
				} else {

				}


			} else {
				start = a[i];
			}
		}

		PUTS(list.Sum() % 1000000007);



	}

}


class Scanner {
	string[] s;
	int i;
	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}
}

Submission Info

Submission Time
Task C - タコヤ木
User parfait
Language C# (Mono 2.10.8.1)
Score 0
Code Size 1788 Byte
Status WA
Exec Time 165 ms
Memory 8824 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 0 / 50 0 / 30 0 / 20
Status
RE × 3
WA × 3
RE × 11
WA × 5
RE × 21
WA × 7
RE × 29
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt
Subtask2 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt
Subtask3 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt
Case Name Status Exec Time Memory
sample_01.txt RE 157 ms 8404 KB
sample_02.txt RE 154 ms 8444 KB
sample_03.txt RE 152 ms 8444 KB
subtask1_01.txt WA 152 ms 8584 KB
subtask1_02.txt WA 156 ms 8632 KB
subtask1_03.txt RE 150 ms 8528 KB
subtask1_04.txt RE 152 ms 8444 KB
subtask1_05.txt RE 154 ms 8512 KB
subtask1_06.txt RE 152 ms 8444 KB
subtask1_07.txt RE 162 ms 8452 KB
subtask1_08.txt WA 149 ms 8584 KB
subtask1_09.txt RE 153 ms 8448 KB
subtask1_10.txt RE 153 ms 8448 KB
subtask1_11.txt RE 153 ms 8452 KB
subtask1_12.txt RE 154 ms 8440 KB
subtask2_01.txt WA 154 ms 8584 KB
subtask2_02.txt RE 153 ms 8404 KB
subtask2_03.txt RE 153 ms 8452 KB
subtask2_04.txt RE 156 ms 8440 KB
subtask2_05.txt RE 155 ms 8576 KB
subtask2_06.txt RE 157 ms 8524 KB
subtask2_07.txt RE 152 ms 8572 KB
subtask2_08.txt WA 157 ms 8692 KB
subtask2_09.txt RE 155 ms 8576 KB
subtask2_10.txt RE 154 ms 8576 KB
subtask2_11.txt RE 159 ms 8644 KB
subtask2_12.txt RE 156 ms 8568 KB
subtask3_01.txt WA 158 ms 8584 KB
subtask3_02.txt RE 157 ms 8404 KB
subtask3_03.txt RE 153 ms 8444 KB
subtask3_04.txt RE 157 ms 8568 KB
subtask3_05.txt RE 158 ms 8448 KB
subtask3_06.txt RE 159 ms 8576 KB
subtask3_07.txt RE 161 ms 8580 KB
subtask3_08.txt WA 165 ms 8824 KB
subtask3_09.txt RE 160 ms 8572 KB
subtask3_10.txt RE 161 ms 8704 KB
subtask3_11.txt RE 158 ms 8572 KB
subtask3_12.txt RE 158 ms 8708 KB