結果

問題 No.647 明太子
ユーザー michonz4michonz4
提出日時 2019-12-27 09:08:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 4,500 ms
コード長 830 bytes
コンパイル時間 1,006 ms
コンパイル使用メモリ 80,132 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 10:35:56
合計ジャッジ時間 2,192 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 38 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 45 ms
5,376 KB
testcase_18 AC 47 ms
5,376 KB
testcase_19 AC 10 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 34 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> v1(n, vector<int>(2));
  for (int i=0; i<n; i++) {
    cin >> v1[i][0] >> v1[i][1];
  }

  int m;
  cin >> m;
  vector<vector<int>> v2(m, vector<int>(4));
  for (int i=0; i<m; i++) {
    cin >> v2[i][2] >> v2[i][3];
    v2[i][1]=i+1;
  }

  for (int i=0; i<m; i++) {
    for (int j=0; j<n; j++) {
      if (v2[i][2]<=v1[j][0] && v2[i][3]>=v1[j][1]) v2[i][0]++;
    }
  }

  sort(v2.begin(), v2.end(), [](auto &L, auto &R){return L[0]==R[0] ? L[1]<R[1]: L[0]>R[0];});

  int max=v2[0][0];
  if (!max) {
    cout << 0 << endl;
    return 0;
  } else {
    for (int i=0; i<m; i++) {
      if (v2[i][0]==max) {
        cout << v2[i][1] << endl;
      } else {
        return 0;
      }
    }
  }
}
0