Submission #1249579
Source Code Expand
Copy
using System;using System.Collections;using System.Collections.Generic;using System.Diagnostics;using System.IO;using System.Linq;using System.Numerics;namespace Codeforces{internal class Template{private void Solve(){var n = cin.NextLong();var t = cin.NextLong();var lastTo = 0L;var res = 0L;for (var i = 0; i < n; i++){
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; namespace Codeforces { internal class Template { private void Solve() { var n = cin.NextLong(); var t = cin.NextLong(); var lastTo = 0L; var res = 0L; for (var i = 0; i < n; i++) { var from = cin.NextLong(); var to = from + t; if (from < lastTo) { from = lastTo; } res += to - from; lastTo = to; } Console.WriteLine(res); } private static readonly Scanner cin = new Scanner(); private static void Main() { #if DEBUG var inputText = File.ReadAllText(@"..\..\input.txt"); var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries); var consoleOut = Console.Out; for (var i = 0; i < testCases.Length; i++) { var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries); Console.SetIn(new StringReader(parts[0].Trim())); var stringWriter = new StringWriter(); Console.SetOut(stringWriter); var sw = Stopwatch.StartNew(); new Template().Solve(); sw.Stop(); var output = stringWriter.ToString(); Console.SetOut(consoleOut); var color = ConsoleColor.Green; var status = "Passed"; if (parts[1].Trim() != output.Trim()) { color = ConsoleColor.Red; status = "Failed"; } Console.ForegroundColor = color; Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds); } Console.ReadLine(); Console.ReadKey(); #else new Template().Solve(); Console.ReadLine(); #endif } } internal class Scanner { private string[] s = new string[0]; private int i; private readonly char[] cs = { ' ' }; public string NextString() { if (i < s.Length) return s[i++]; var line = Console.ReadLine() ?? string.Empty; s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 1; return s.First(); } public double NextDouble() { return double.Parse(NextString()); } public int NextInt() { return int.Parse(NextString()); } public long NextLong() { return long.Parse(NextString()); } } }
Submission Info
Submission Time | |
---|---|
Task | C - Sentou |
User | Neverauskas |
Language | C# (Mono 4.6.2.0) |
Score | 300 |
Code Size | 2339 Byte |
Status | AC |
Exec Time | 120 ms |
Memory | 28832 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0, example1, example2, example3, example4 |
All | example0, example1, example2, example3, example4, maxrand0, maxrand1, maxrand2, rand0, rand1, rand2, rand3, rand4 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example0 | AC | 23 ms | 9172 KB |
example1 | AC | 22 ms | 11220 KB |
example2 | AC | 22 ms | 9172 KB |
example3 | AC | 22 ms | 9172 KB |
example4 | AC | 23 ms | 11220 KB |
maxrand0 | AC | 117 ms | 28832 KB |
maxrand1 | AC | 120 ms | 27168 KB |
maxrand2 | AC | 118 ms | 25120 KB |
rand0 | AC | 23 ms | 11296 KB |
rand1 | AC | 24 ms | 13228 KB |
rand2 | AC | 24 ms | 13228 KB |
rand3 | AC | 23 ms | 11168 KB |
rand4 | AC | 23 ms | 11220 KB |