結果
問題 | No.647 明太子 |
ユーザー |
![]() |
提出日時 | 2018-02-09 23:02:18 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 46 ms / 4,500 ms |
コード長 | 903 bytes |
コンパイル時間 | 697 ms |
コンパイル使用メモリ | 105,344 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 23:49:34 |
合計ジャッジ時間 | 1,718 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
import std.stdio;import std.range;import std.array;import std.string;import std.conv;import std.typecons;import std.algorithm;void main(){int n = readln.chomp.to!int;int[] a, b;foreach (i; 0..n) {auto v = readln.chomp.split.map!(to!int);a ~= v.front;b ~= v.back;}int m = readln.chomp.to!int;int[] x, y;foreach (i; 0..m) {auto v = readln.chomp.split.map!(to!int);x ~= v.front;y ~= v.back;}alias Node = Tuple!(int, "count", int, "index");Node[] arr;foreach (i; 0..m) {int cnt = 0;foreach (j; 0..n) {if (x[i] > a[j]) {continue;}if (y[i] < b[j]) {continue;}++cnt;}arr ~= Node(cnt, i + 1);}auto val = arr.reduce!max;if (val.count) {foreach (w; arr.filter!(a => a.count == val.count)) {writeln = w.index;}} else {0.writeln;}}