Submission #3009491


Source Code Expand

using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = long.Parse(line[0]);
        var k = long.Parse(line[1]);
        var wd = new long[n, 2];
        var maxa = 0L;
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            wd[i, 0] = long.Parse(line[0]);
            wd[i, 1] = long.Parse(line[1]);
            maxa = Math.Max(maxa, wd[i, 0] + (k - 1) * wd[i, 1] + 100L);
        }
        Console.WriteLine(getAns(wd, k, maxa));
    }
    public static long getAns(long[,] wd, long k, long maxa)
    {
        var ok = maxa;
        var ng = 0L;
        while (ok - ng > 1)
        {
            var mid = (ok + ng) / 2L;
            if (getFLower(wd, mid, k)) ok = mid;
            else ng = mid;
        }
        return ok;
    }
    public static bool getFLower(long[,] wd, long a, long k)
    {
        var n = wd.GetLength(0);
        var f = 0L;
        for (int i = 0; i < n; i++)
            f += (a - wd[i, 0]) / wd[i, 1] + 1;
        return f >= k;
    }
}

Submission Info

Submission Time
Task C - Garden
User bluemegane
Language C# (Mono 4.6.2.0)
Score 0
Code Size 1164 Byte
Status WA
Exec Time 250 ms
Memory 17300 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 3
AC × 10
WA × 13
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23
Case Name Status Exec Time Memory
a01 AC 20 ms 9044 KB
a02 AC 21 ms 13140 KB
a03 AC 19 ms 9044 KB
b04 AC 20 ms 13140 KB
b05 AC 247 ms 14520 KB
b06 AC 236 ms 16572 KB
b07 AC 241 ms 14520 KB
b08 AC 247 ms 16568 KB
b09 AC 242 ms 14520 KB
b10 AC 242 ms 14520 KB
b11 WA 243 ms 14520 KB
b12 WA 243 ms 16572 KB
b13 WA 236 ms 14524 KB
b14 WA 236 ms 16572 KB
b15 WA 242 ms 16568 KB
b16 WA 239 ms 16572 KB
b17 WA 250 ms 14524 KB
b18 WA 239 ms 16572 KB
b19 WA 239 ms 14524 KB
b20 WA 233 ms 17300 KB
b21 WA 233 ms 16572 KB
b22 WA 235 ms 16572 KB
b23 WA 232 ms 14524 KB