Submission #18874309


Source Code Expand

Copy
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const H = readInt();
      const W = readInt();
      auto A = new long[][](H, W);
      foreach (x; 0 .. H) foreach (y; 0 .. W) {
        A[x][y] = readLong();
      }
      
      long mn = long.max;
      foreach (x; 0 .. H) foreach (y; 0 .. W) {
        chmin(mn, A[x][y]);
      }
      long ans;
      foreach (x; 0 .. H) foreach (y; 0 .. W) {
        ans += (A[x][y] - mn);
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}

Submission Info

Submission Time
Task B - Blocks on Grid
User hos_lyric
Language D (LDC 1.20.1)
Score 200
Code Size 1713 Byte
Status AC
Exec Time 9 ms
Memory 3396 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 14
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_11.txt, random_12.txt, random_13.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 9 ms 3308 KB
random_02.txt AC 3 ms 3324 KB
random_03.txt AC 7 ms 3104 KB
random_04.txt AC 4 ms 3160 KB
random_05.txt AC 3 ms 3160 KB
random_06.txt AC 3 ms 3276 KB
random_07.txt AC 4 ms 3228 KB
random_08.txt AC 4 ms 3224 KB
random_11.txt AC 5 ms 3360 KB
random_12.txt AC 4 ms 3380 KB
random_13.txt AC 4 ms 3256 KB
sample_01.txt AC 3 ms 3168 KB
sample_02.txt AC 3 ms 3164 KB
sample_03.txt AC 3 ms 3396 KB