Submission #112725
Source Code Expand
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { List<RainningTimes> rainningTimesList = new List<RainningTimes>(); int N = int.Parse(Console.ReadLine()); for (int i = 0; i < N; i++) { var array = Console.ReadLine().Split('-').Select(int.Parse).ToArray(); int s = array.ElementAtOrDefault(0); int e = array.ElementAtOrDefault(1); int s1 = int.Parse(s.ToString()[3].ToString()); if (s1 == 0) { } else if (s1 < 5) s -= s1; else if (s1 > 5) s -= s1 - 5; int e1 = int.Parse(e.ToString()[3].ToString()); if (e1 == 0) { } else if (e1 < 5) e += 5 - e1; else if (e1 > 5) e += 10 - e1; int length = rainningTimesList.Count; for (int j = 0; j < length;j++ ) { Console.WriteLine(" "+rainningTimesList[j].Start+":"+rainningTimesList[j].End+"について行います."); //Start地点が枠内 if (JudgeBetween(s, rainningTimesList[j])) { //End地点が枠内 if (JudgeBetween(e, rainningTimesList[j])) { Console.WriteLine(" Start 枠内 : End 枠内"); break; }//何もしない else//End地点が枠外 { rainningTimesList[j].End = e; Console.WriteLine(" Start 枠内 : End 枠外"); break; } } else//Start地点が枠外 { //End地点が枠内 if (JudgeBetween(e, rainningTimesList[j])) { rainningTimesList[j].Start = s; Console.WriteLine(" Start 枠外 : End 枠内"); break; } else//End地点が枠外 if (rainningTimesList[j].Start > s && rainningTimesList[j].End < e) { rainningTimesList[j].Start = s; rainningTimesList[j].End = e; Console.WriteLine(" Start 枠外 : End 枠外で,Start > s && End < eが認識されました"); break; } else { rainningTimesList.Add(new RainningTimes(s, e)); Console.WriteLine(" 新たな要素ですので追加致します."); break; } } } if (rainningTimesList.Count == 0) rainningTimesList.Add(new RainningTimes(s, e)); } for (int i = rainningTimesList.Count - 1; i >= 0; i--) { int s = rainningTimesList[i].Start; int e = rainningTimesList[i].End; for (int j = i - 1; j >= 0; j--) { //Start地点が枠内 if (JudgeBetween(s, rainningTimesList[j])) { //End地点が枠内 if (JudgeBetween(e, rainningTimesList[j])) { break; }//何もしない else//End地点が枠外 { rainningTimesList[j].End = e; rainningTimesList.RemoveAt(i); break; } } else//Start地点が枠外 { //End地点が枠内 if (JudgeBetween(e, rainningTimesList[j])) { rainningTimesList[j].Start = s; rainningTimesList.RemoveAt(i); break; } else//End地点が枠外 if (rainningTimesList[j].Start > s && rainningTimesList[j].End < e) { rainningTimesList[j].Start = s; rainningTimesList[j].End = e; rainningTimesList.RemoveAt(i); break; } } } } for (int i = 0; i < rainningTimesList.Count; i++) Console.WriteLine(rainningTimesList[i].Start + "-" + rainningTimesList[i].End); } //timeがrainningTimesの枠内かどうか falseは枠外 private static bool JudgeBetween(int time , RainningTimes rainningTimes) { if (rainningTimes.Start <= time && rainningTimes.End >= time) return true; return false; } } class RainningTimes { public RainningTimes(int start, int end) { Start = start; End = end; } public int Start { get; set; } public int End { get; set; } }
Submission Info
Submission Time | |
---|---|
Task | A - 積雪深差 |
User | pattyo |
Language | C# (Mono 2.10.8.1) |
Score | 0 |
Code Size | 5859 Byte |
Status | RE |
Exec Time | 130 ms |
Memory | 6392 KB |
Judge Result
Set Name | all | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||
Status |
|
Set Name | Test Cases |
---|---|
all | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | RE | 130 ms | 6372 KB |
00_sample_02.txt | WA | 109 ms | 5876 KB |
00_sample_03.txt | RE | 125 ms | 6384 KB |
test_01.txt | WA | 114 ms | 5796 KB |
test_02.txt | RE | 126 ms | 6372 KB |
test_03.txt | WA | 106 ms | 5868 KB |
test_04.txt | RE | 124 ms | 6384 KB |
test_05.txt | RE | 122 ms | 6384 KB |
test_06.txt | RE | 124 ms | 6384 KB |
test_07.txt | RE | 120 ms | 6392 KB |
test_08.txt | RE | 124 ms | 6376 KB |
test_09.txt | RE | 126 ms | 6388 KB |
test_10.txt | RE | 125 ms | 6256 KB |
test_11.txt | RE | 125 ms | 6380 KB |
test_12.txt | RE | 122 ms | 6372 KB |
test_13.txt | RE | 125 ms | 6376 KB |
test_14.txt | RE | 124 ms | 6372 KB |
test_15.txt | RE | 120 ms | 6388 KB |
test_16.txt | RE | 130 ms | 6296 KB |
test_17.txt | RE | 128 ms | 6364 KB |