AtCoder Regular Contest 069

Submission #1352140

Source codeソースコード

//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class E { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var a = G();
		var t = new List<P>();
		var n = new long[N];
		for (var i = 0; i < N; i++) t.Add(new P(a[i], i));
		t.Sort();
		var m = N + 1;
		for (var i = 0; i < N; i++)
		{
			var d = i < N - 1 ? t[i].H - t[i + 1].H : t[i].H;
			m = Min(m, t[i].I);
			n[m] += (i + 1L) * d;
		}
		for (var i = 0; i < N; i++) WriteLine(n[i]);
	}
}
struct P : IComparable<P>
{
	public int H, I;
	public P(int h, int i)
	{
		H = h;
		I = i;
	}
	public int CompareTo(P x)
	{
		var c = x.H.CompareTo(H);
		return c == 0 ? x.I.CompareTo(I) : c;
	}
}

Submission

Task問題 E - Frequency
User nameユーザ名 selpo
Created time投稿日時
Language言語 C# (Mono 4.6.2.0)
Status状態 AC
Score得点 700
Source lengthソースコード長 1413 Byte
File nameファイル名
Exec time実行時間 138 ms
Memory usageメモリ使用量 33116 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_example_01.txt,00_example_02.txt
All 700 / 700 00_example_01.txt,00_example_02.txt,01.txt,02.txt,03.txt,04.txt,05.txt,06.txt,07.txt,08.txt,09.txt,10.txt,11.txt,12.txt,13.txt,14.txt,15.txt,16.txt,17.txt,18.txt,19.txt,20.txt,21.txt,22.txt,23.txt,24.txt,25.txt,26.txt,27.txt,28.txt,29.txt,30.txt,31.txt,32.txt,33.txt,34.txt,35.txt,36.txt,37.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_example_01.txt AC 28 ms 11732 KB
00_example_02.txt AC 29 ms 11732 KB
01.txt AC 28 ms 9504 KB
02.txt AC 34 ms 12256 KB
03.txt AC 29 ms 11732 KB
04.txt AC 29 ms 9648 KB
05.txt AC 28 ms 9684 KB
06.txt AC 29 ms 13780 KB
07.txt AC 28 ms 9684 KB
08.txt AC 29 ms 13780 KB
09.txt AC 37 ms 12640 KB
10.txt AC 28 ms 9684 KB
11.txt AC 122 ms 28892 KB
12.txt AC 123 ms 28892 KB
13.txt AC 123 ms 30772 KB
14.txt AC 121 ms 26844 KB
15.txt AC 122 ms 26844 KB
16.txt AC 117 ms 29404 KB
17.txt AC 127 ms 29236 KB
18.txt AC 112 ms 29020 KB
19.txt AC 94 ms 22368 KB
20.txt AC 119 ms 26204 KB
21.txt AC 28 ms 11732 KB
22.txt AC 28 ms 9500 KB
23.txt AC 29 ms 11732 KB
24.txt AC 34 ms 12384 KB
25.txt AC 29 ms 11564 KB
26.txt AC 29 ms 11680 KB
27.txt AC 29 ms 9504 KB
28.txt AC 128 ms 32948 KB
29.txt AC 128 ms 33112 KB
30.txt AC 138 ms 29144 KB
31.txt AC 128 ms 33116 KB
32.txt AC 126 ms 29020 KB
33.txt AC 110 ms 30428 KB
34.txt AC 110 ms 28212 KB
35.txt AC 110 ms 26332 KB
36.txt AC 110 ms 32476 KB
37.txt AC 109 ms 28380 KB