Submission #179764


Source Code Expand

import static java.util.Arrays.deepToString;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.text.DecimalFormat;
 
public class Main {
    private static final boolean isDebug = false;
    
    int N;
    
    static final String[] DIRECTION = {"N", "NNE", "NE", "ENE",
                                          "E", "ESE", "SE", "SSE",
                                          "S", "SSW", "SW", "WSW",
                                          "W", "WNW", "NW", "NNW",
    };
    
    static double[] WIND_POWER = {0.2, 1.5, 3.3, 5.4,
                                    7.9, 10.7, 13.8, 17.1,
                                    20.7, 24.4, 28.4, 32.6
    };
    
    
    boolean[][] isLain = new boolean[25][12];
    

    int[] imos = new int[24*12 + 1];
    public final void solve5() throws Throwable { 
        int N = readBufInt();
        for (int i = 0; i < N; i++) {
            String[] line = br.readLine().split("-");
            int fromH = Integer.parseInt(line[0].substring(0,2));
            int fromM = Integer.parseInt(line[0].substring(2,4)) / 5;

            int toH = Integer.parseInt(line[1].substring(0,2));
            int toM = Integer.parseInt(line[1].substring(2,4));
            int tmp = 0;
            if (toM % 5 > 0) {
                tmp++;
            }
            toM = toM / 5 + tmp;
            
            imos[fromH * 12 + fromM]++;
            imos[toH * 12 + toM]--;
        }        

        DecimalFormat format = new DecimalFormat("00");
        
        int s = 0;
        boolean isCall = false;
        int sum = 0;
        for (int i = 0; i < 24 * 12 + 1; i++) {
            sum+=imos[i];
            if (sum >= 1) {
                if (!isCall) {
                    isCall = true;
                    s = i;
                }
            } else {
                if (isCall) {
                    isCall = false;
                    int fromH = s / 12;
                    int fromM = (s % 12) * 5;
                    int toH = i / 12;
                    int toM = (i % 12) * 5;

                    pw.println(format.format(fromH) + 
                            format.format(fromM) + 
                            "-" +
                            format.format(toH) + 
                            format.format(toM));
                }
            }
        }
        
    }
    
    
    public final void solve4() throws Throwable { 
        
        int N = readBufInt();
        for (int i = 0; i < N; i++) {
            String[] line = br.readLine().split("-");
            int fromH = Integer.parseInt(line[0].substring(0,2));
            int fromM = Integer.parseInt(line[0].substring(2,4)) / 5;

            int toH = Integer.parseInt(line[1].substring(0,2));
            int toM = Integer.parseInt(line[1].substring(2,4));
            int tmp = 0;
            if (toM % 5 > 0) {
                tmp++;
            }
            toM = toM / 5 + tmp;
            
            d(fromH + " " + fromM);
            d(toH + " " + toM);
            
            
            boolean isFirstLine = true;
            for (; fromH <= toH; fromH++) {
                int loopFromM = 0;
                int loopToM = 12;
                
                if (isFirstLine) {
                    loopFromM = fromM;
                    isFirstLine = false;
                }
                if (fromH == toH) {
                    loopToM = toM;
                }
                
                for (;loopFromM < loopToM; loopFromM++) {
                    isLain[fromH][loopFromM] = true;
                }
                
            }
        }

        boolean isCall = false;
        int callH = 0;
        int callM = 0;
        DecimalFormat format = new DecimalFormat("00");
        for (int i = 0; i <= 24; i++) {
            for (int j = 0; j < 12; j++) {
                if (isCall) {
                    if (!isLain[i][j]) {
                        pw.println(format.format(callH) + 
                                   format.format(callM * 5) + 
                                   "-" +
                                   format.format(i) + 
                                   format.format(j * 5)
                                   );
                        isCall = false;
                    }
                } else {
                    if (isLain[i][j]) {
                        isCall = true;
                        callH = i;
                        callM = j;
                    }
                }
            }
        }
        
        
        
    }
    public final void solve2() throws Throwable { 
        startTime = System.currentTimeMillis();
        
        int m = readBufInt();
        
        int K = 1000;
 
        String V;
        
        if (m < 0.1 * K) {
            V = "00";
        } else if (m <= 5 * K) {
            int vInt = m * 10 / K ;
            if (vInt / 10 < 1) {
                V = "0" + vInt;
            } else {
                V = String.valueOf(vInt);
            }
        } else if (m <= 30 * K) {
            int vInt = m / K + 50;
            V = String.valueOf(vInt);
        } else if (m <= 70 * K) {
            int vInt = (m / K - 30) / 5 + 80;
            V = String.valueOf(vInt);
        } else {
            V = "89";
        }
        
        pw.println(V);
    }
    
    
    public final void solve3() throws Throwable { 
        startTime = System.currentTimeMillis();
        
        int dis = readBufInt();
        int deg = readBufInt();
        
        BigDecimal wPower = new BigDecimal(deg).divide(new BigDecimal(60), 1, BigDecimal.ROUND_HALF_UP);
        int wIndex = 12;
        for (int i = 0; i < 12; i++) {
            if (wPower.compareTo(new BigDecimal(WIND_POWER[i]).setScale(1, BigDecimal.ROUND_HALF_EVEN ))<= 0) {
                wIndex = i;
                break;
            }
        }

        String Dir = "C";;

        if (wIndex != 0) {
            int range = 36000 / 16;
            int start = range / 2;
            
            int dir = (dis * 10 + start) / range;
            if (dir > 15) dir = 0;
            Dir = DIRECTION[dir];
        }
        
        pw.println(Dir + " " + wIndex);
    }
    
    private static long gcd(long n1, long n2) {
        return (n2 == 0)?n1:gcd(n2, n1%n2);
    }

    private static int gcd(int n1, int n2) {
        return (n2 == 0)?n1:gcd(n2, n1%n2);
    }
    private int brPos = 0;
    private int[] brBuf = null;
    
    private final int readBufInt() throws IOException {
        if (brBuf == null || brBuf.length == brPos) {
            brBuf = readIntArray();
            brPos = 0;
        }
        return brBuf[brPos++];
    }

    private final int readInt() throws IOException {
        return Integer.parseInt(br.readLine());
    }

    private final long readLong() throws IOException {
        return Long.parseLong(br.readLine());
    }

    private final int[] readIntArray() throws IOException {
        String[] s = readStrArray();
        int cnt = s.length;
        int[] out = new int[cnt];
        for (int i = 0; i < cnt; i++) out[i] = Integer.parseInt(s[i]);
        return out;
    }

    private final char[] readCharArray() throws IOException {
        String[] s = readStrArray();
        int cnt = s.length;
        char[] out = new char[cnt];
        for (int i = 0; i < cnt; i++) out[i] = s[i].charAt(0);
        return out;
    }

    private final long[] readLongArray() throws IOException {
        String[] s = readStrArray();
        int cnt = s.length;
        long[] out = new long[cnt];
        for (int i = 0; i < cnt; i++) out[i] = Long.parseLong(s[i]);
        return out;
    }

    private final String[] readStrArray() throws IOException {
        String[] s = br.readLine().split(" ");
        return s;
    }

    static long startTime;
    public static void main(String[] args) {
        Main app = new Main();
        try {
            app.br = new BufferedReader(new InputStreamReader(System.in));
            app.solve5();
        } catch(Throwable e) {
            e.printStackTrace();
        } finally {
            try { app.br.close();} catch (Exception igunore) {}
        }
        d(System.currentTimeMillis() - startTime + " ms");
        pw.flush();
        pw.close();
    }

   static final void d(Object ... o) {
       if (isDebug) pw.println(deepToString(o));
   }

   BufferedReader br = null;
   static PrintWriter pw = new PrintWriter(System.out);
}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User tochukaso
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 8847 Byte
Status AC
Exec Time 710 ms
Memory 35056 KB

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 48
Set Name Test Cases
all 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.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, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 514 ms 22600 KB
00_sample_02.txt AC 419 ms 22396 KB
00_sample_03.txt AC 417 ms 22420 KB
cho_cho_chokudai.txt AC 611 ms 33872 KB
chokudai_ga_cho.txt AC 619 ms 33456 KB
test_01.txt AC 429 ms 22868 KB
test_02.txt AC 420 ms 22740 KB
test_03.txt AC 415 ms 22876 KB
test_04.txt AC 436 ms 22740 KB
test_05.txt AC 426 ms 22992 KB
test_06.txt AC 437 ms 22984 KB
test_07.txt AC 437 ms 22604 KB
test_08.txt AC 436 ms 22412 KB
test_09.txt AC 437 ms 23248 KB
test_10.txt AC 450 ms 23320 KB
test_11.txt AC 428 ms 23324 KB
test_12.txt AC 439 ms 23156 KB
test_13.txt AC 429 ms 23116 KB
test_14.txt AC 428 ms 23252 KB
test_15.txt AC 437 ms 23384 KB
test_16.txt AC 411 ms 22540 KB
test_17.txt AC 471 ms 23240 KB
test_18.txt AC 418 ms 23248 KB
test_19.txt AC 432 ms 23120 KB
test_20.txt AC 442 ms 23020 KB
test_21.txt AC 663 ms 34440 KB
test_22.txt AC 676 ms 33708 KB
test_23.txt AC 625 ms 34368 KB
test_24.txt AC 650 ms 34520 KB
test_25.txt AC 672 ms 34504 KB
test_26.txt AC 667 ms 35048 KB
test_27.txt AC 649 ms 34936 KB
test_28.txt AC 684 ms 34956 KB
test_29.txt AC 415 ms 22408 KB
test_30.txt AC 415 ms 22416 KB
test_31.txt AC 512 ms 28020 KB
test_32.txt AC 416 ms 22480 KB
test_33.txt AC 639 ms 34076 KB
test_34.txt AC 418 ms 22404 KB
test_35.txt AC 434 ms 22872 KB
test_36.txt AC 679 ms 34312 KB
test_37.txt AC 710 ms 34420 KB
test_38.txt AC 662 ms 32788 KB
test_39.txt AC 672 ms 33828 KB
test_40.txt AC 625 ms 32980 KB
test_41.txt AC 632 ms 34520 KB
test_42.txt AC 674 ms 35056 KB
test_43.txt AC 680 ms 35000 KB