Submission #1566923
Source Code Expand
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Globalization; using System.Diagnostics; class Myon { public Myon() { } public static int Main() { new Myon().calc(); return 0; } Scanner cin; void calc() { cin = new Scanner(); int X = cin.nextInt(); int K = cin.nextInt(); int[] r = new int[K + 1]; for (int i = 0; i < K; i++) { r[i] = cin.nextInt(); } r[K] = int.MaxValue / 2; int Q = cin.nextInt(); int[] t = new int[Q]; int[] a = new int[Q]; for (int i = 0; i < Q; i++) { t[i] = cin.nextInt(); a[i] = cin.nextInt(); } int now = 0; int leftPoint = 0; int leftValue = 0; int rightPoint = X; int rightValue = X; int tp = 0; for (int i = 0; i < K + 1; i++) { while(tp < t.Length && t[tp] <= r[i]) { int nowA; if (a[tp] <= leftPoint) nowA = leftValue; else if (a[tp] >= rightPoint) nowA = rightValue; else nowA = leftValue + (a[tp] - leftPoint); if (i % 2 == 0) nowA -= (t[tp] - now); else nowA += (t[tp] - now); if (nowA < 0) nowA = 0; if (nowA > X) nowA = X; Console.WriteLine(nowA); tp++; } int move = r[i] - now; if (i % 2 == 0) { leftValue -= move; if (leftValue < 0) { leftPoint -= leftValue; leftValue = 0; } rightValue -= move; if (rightValue < 0) rightValue = 0; } else { leftValue += move; if (leftValue > X) { leftValue = X; } rightValue += move; if (rightValue >= X) { rightPoint -= (rightValue - X); rightValue = X; } } now = r[i]; } } //swap void swap<T>(ref T a, ref T b) { T c = a; a = b; b = c; } long calcT(long ax, long ay, long bx, long by) { return (ax * by) - (bx * ay); } } 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++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } }
Submission Info
Submission Time | |
---|---|
Task | F - Sandglass |
User | chokudai |
Language | C# (Mono 4.6.2.0) |
Score | 700 |
Code Size | 4111 Byte |
Status | AC |
Exec Time | 680 ms |
Memory | 30404 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt, 1_036.txt, 1_037.txt, 1_038.txt, 1_039.txt, 1_040.txt, 1_041.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 22 ms | 13140 KB |
0_001.txt | AC | 21 ms | 11220 KB |
0_002.txt | AC | 22 ms | 13140 KB |
1_003.txt | AC | 609 ms | 21704 KB |
1_004.txt | AC | 624 ms | 24520 KB |
1_005.txt | AC | 615 ms | 23364 KB |
1_006.txt | AC | 638 ms | 21704 KB |
1_007.txt | AC | 615 ms | 24648 KB |
1_008.txt | AC | 616 ms | 23364 KB |
1_009.txt | AC | 632 ms | 21704 KB |
1_010.txt | AC | 631 ms | 30404 KB |
1_011.txt | AC | 620 ms | 25412 KB |
1_012.txt | AC | 617 ms | 23876 KB |
1_013.txt | AC | 623 ms | 26436 KB |
1_014.txt | AC | 622 ms | 29636 KB |
1_015.txt | AC | 643 ms | 24004 KB |
1_016.txt | AC | 639 ms | 28868 KB |
1_017.txt | AC | 640 ms | 25540 KB |
1_018.txt | AC | 642 ms | 24004 KB |
1_019.txt | AC | 639 ms | 24900 KB |
1_020.txt | AC | 647 ms | 23616 KB |
1_021.txt | AC | 621 ms | 21956 KB |
1_022.txt | AC | 647 ms | 24640 KB |
1_023.txt | AC | 649 ms | 23744 KB |
1_024.txt | AC | 616 ms | 21952 KB |
1_025.txt | AC | 641 ms | 27200 KB |
1_026.txt | AC | 670 ms | 25920 KB |
1_027.txt | AC | 622 ms | 28096 KB |
1_028.txt | AC | 633 ms | 25024 KB |
1_029.txt | AC | 680 ms | 23996 KB |
1_030.txt | AC | 650 ms | 22080 KB |
1_031.txt | AC | 634 ms | 25024 KB |
1_032.txt | AC | 679 ms | 30268 KB |
1_033.txt | AC | 619 ms | 16580 KB |
1_034.txt | AC | 608 ms | 16580 KB |
1_035.txt | AC | 647 ms | 27200 KB |
1_036.txt | AC | 625 ms | 16704 KB |
1_037.txt | AC | 619 ms | 16832 KB |
1_038.txt | AC | 646 ms | 25916 KB |
1_039.txt | AC | 605 ms | 16452 KB |
1_040.txt | AC | 624 ms | 14784 KB |
1_041.txt | AC | 680 ms | 28220 KB |