AtCoder Beginner Contest 023

Submission #2114877

Source codeソースコード

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple {
    private int N;
    private int[] H, S;
    void Solve() {
        //input
        N = io.Int;
        H = new int[N];
        S = new int[N];
        for(int i = 0; i < N; ++i) {
            H[i] = io.Int;
            S[i] = io.Int;
        }
        //cal
        var ans = binarySearch(int.MaxValue / 2, 0, check);
        //ret
        WriteLine(ans);
    }
    bool check(int limit) {
        var t = H.Zip(S, (h, s) => new {vH = h, vS = s}).
                  Count(v => ceil(limit - v.vH, v.vS) >= N);
        return t <= 1;
    }
    int ceil(int n, int m) => n % m == 0 ? n / m : n / m + 1;
    int binarySearch(int ng, int ok, Func <int, bool> f) {
        while(Math.Abs(ok - ng) > 1) {
            var mid = (ok + ng) / 2;
            if(f(mid))
                ok = mid;
            else
                ng = mid;
        }
        return ok;
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        if(st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}

Submission

Task問題 D - 射撃王
User nameユーザ名 sora
Created time投稿日時
Language言語 C# (Mono 4.6.2.0)
Status状態 WA
Score得点 0
Source lengthソースコード長 2396 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0-sample01.txt,subtask0-sample02.txt
Subtask1 0 / 30 subtask0-sample01.txt,subtask0-sample02.txt,subtask1-01.txt,subtask1-02.txt,subtask1-03.txt,subtask1-04.txt,subtask1-05.txt,subtask1-06.txt,subtask1-07.txt,subtask1-08.txt,subtask1-09.txt,subtask1-10.txt,subtask1-11.txt,subtask1-12.txt,subtask1-13.txt,subtask1-14.txt,subtask1-15.txt
Subtask2 0 / 70 subtask0-sample01.txt,subtask0-sample02.txt,subtask1-01.txt,subtask1-02.txt,subtask1-03.txt,subtask1-04.txt,subtask1-05.txt,subtask1-06.txt,subtask1-07.txt,subtask1-08.txt,subtask1-09.txt,subtask1-10.txt,subtask1-11.txt,subtask1-12.txt,subtask1-13.txt,subtask1-14.txt,subtask1-15.txt,subtask2-01.txt,subtask2-02.txt,subtask2-03.txt,subtask2-04.txt,subtask2-05.txt,subtask2-06.txt,subtask2-07.txt,subtask2-08.txt,subtask2-09.txt,subtask2-10.txt,subtask2-11.txt,subtask2-12.txt,subtask2-13.txt,subtask2-14.txt,subtask2-15.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0-sample01.txt WA
subtask0-sample02.txt AC 24 ms 11220 KB
subtask1-01.txt WA
subtask1-02.txt AC 24 ms 9300 KB
subtask1-03.txt WA
subtask1-04.txt WA
subtask1-05.txt WA
subtask1-06.txt WA
subtask1-07.txt WA
subtask1-08.txt WA
subtask1-09.txt WA
subtask1-10.txt WA
subtask1-11.txt WA
subtask1-12.txt WA
subtask1-13.txt WA
subtask1-14.txt WA
subtask1-15.txt WA
subtask2-01.txt WA
subtask2-02.txt WA
subtask2-03.txt WA
subtask2-04.txt WA
subtask2-05.txt WA
subtask2-06.txt WA
subtask2-07.txt WA
subtask2-08.txt WA
subtask2-09.txt WA
subtask2-10.txt WA
subtask2-11.txt WA
subtask2-12.txt WA
subtask2-13.txt WA
subtask2-14.txt WA
subtask2-15.txt WA