結果
問題 | No.448 ゆきこーだーの雨と雪 (3) |
ユーザー | kuuso1 |
提出日時 | 2016-11-19 00:54:42 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,054 bytes |
コンパイル時間 | 1,110 ms |
コンパイル使用メモリ | 109,184 KB |
実行使用メモリ | 48,392 KB |
最終ジャッジ日時 | 2024-05-04 20:22:54 |
合計ジャッジ時間 | 7,942 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
19,328 KB |
testcase_01 | AC | 26 ms
19,200 KB |
testcase_02 | AC | 26 ms
19,328 KB |
testcase_03 | AC | 26 ms
19,328 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 222 ms
38,016 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 71 ms
26,752 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ Pair[] P = new Pair[N]; Dictionary<long,int> dic = new Dictionary<long,int>(); for(int i=0;i<N;i++){ P[i] = new Pair(T[i],D[i],i); if(dic.ContainsKey(D[i]) == false) dic.Add(D[i],0); dic[D[i]]++; } Array.Sort(P,(p,q) => -p.D.CompareTo(q.D)); bool[] forbid = new bool[N]; for(int i=0;i<N;i++){ var idx = P[i].Idx; var d = P[i].D; var t = P[i].T; if(forbid[idx])break; dic[d]--; int j = idx; while(j>=0 && T[idx] - T[j] < K){ forbid[j] = true; j--; } j = idx; while(j<N && T[j] - T[idx] < K){ forbid[j] = true; j++; } } long yukiMin = (long)2e9;; for(int i=0;i<N;i++){ if(dic[P[i].D] != 0)break; yukiMin = P[i].D; } long ameMax = 0; for(int i=0;i<N;i++){ if(D[i] >= yukiMin)continue; ameMax = Math.Max(ameMax,D[i]); } long yukiDo = 0; bool[] used = new bool[N]; forbid = new bool[N]; for(int i=0;i<N;i++){ if(D[i] >= yukiMin){ used[i] = true; int j=i-1; while(j>=0 && T[i] - T[j] < K){ forbid[j] = true; j--; } yukiDo += D[i]; } } //Console.WriteLine("forbid:{0}",String.Join(" ",forbid)); //Console.WriteLine("used :{0}",String.Join(" ",used)); int[] nxt = new int[N]; int nn=0; for(int i=0;i<N;i++){ while(nn<N && T[nn] - T[i] < K)nn++; nxt[i] = nn; } long[] dp = new long[N+1]; for(int i=0;i<N;i++){ if(forbid[i]){ dp[i+1] = Math.Max(dp[i],dp[i+1]); }else if(used[i]){ dp[nxt[i]] = dp[i]; i = nxt[i] - 1; }else{ dp[i+1] = Math.Max(dp[i],dp[i+1]); dp[nxt[i]] = Math.Max(dp[i],dp[nxt[i]]+D[i]); } } //Console.WriteLine("Dsum = {0}",D.Sum()); //Console.WriteLine("yukiDo = {0}",yukiDo); //Console.WriteLine("dp = {0}",String.Join(" ",dp)); long ameDo = D.Sum() - yukiDo - dp[N]; Console.WriteLine("{0}\n{1}",ameMax,ameDo); } class Pair{ public long T,D; public int Idx; public Pair(long t,long d,int i){ T = t; D= d; Idx = i; } } int N,K; long[] T; long[] D; public Sol(){ var d = ria(); N = d[0]; K = d[1]; T = new long[N]; D = new long[N]; for(int i=0;i<N;i++){ var dd = rla(); T[i] = dd[0]; D[i] = dd[1]; } } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);} static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }