結果
| 問題 |
No.647 明太子
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-02-09 23:17:45 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 49 ms / 4,500 ms |
| コード長 | 1,234 bytes |
| コンパイル時間 | 778 ms |
| コンパイル使用メモリ | 102,388 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 23:49:42 |
| 合計ジャッジ時間 | 1,540 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int n;
int[] a, b;
scan(n);
a = new int[](n);
b = new int[](n);
iota(n).each!(i => scan(a[i], b[i]));
int m;
scan(m);
auto cnt = new int[](m);
foreach (i ; 0 .. m) {
int xi, yi;
scan(xi, yi);
foreach (j ; 0 .. n) {
if (xi <= a[j] && yi >= b[j]) cnt[i]++;
}
}
debug {
writeln(cnt);
}
auto cm = cnt.reduce!max;
if (cm == 0) {
writeln(0);
return;
}
auto ans = iota(m).filter!(i => cnt[i] == cm).map!(x => x + 1).array;
ans.each!(i => writeln(i));
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.primitives;
auto line = readln().splitter();
foreach (ref arg; args) {
arg = line.front.to!(typeof(arg));
line.popFront();
}
assert(line.empty);
}
void fillAll(R, T)(ref R arr, T value) {
static if (is(typeof(arr[] = value))) {
arr[] = value;
}
else {
foreach (ref e; arr) {
fillAll(e, value);
}
}
}