結果

問題 No.647 明太子
ユーザー AQUA16573837
提出日時 2018-04-03 19:48:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 37 ms / 4,500 ms
コード長 858 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 40,776 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-27 02:54:45
合計ジャッジ時間 1,494 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
main.cpp:20:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |                 scanf("%d %d", a + i, b + i);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |         scanf("%d", &m);
      |         ~~~~~^~~~~~~~~~
main.cpp:25:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |                 scanf("%d %d", &x, &y);
      |                 ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include <stdio.h>
#include <algorithm>
#include <deque>
using namespace std;
using ll = long long;
void solve();
int main() {
solve();
#ifdef DBG
while (true);
#endif
}
//647
void solve() {
int n, a[10000], b[10000], m, c[1001], x, y;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d %d", a + i, b + i);
scanf("%d", &m);
c[0] = 0;
for (int i = 1; i <= m; i++) {
c[i] = 0;
scanf("%d %d", &x, &y);
for (int j = 0; j < n; j++)
if (x <= a[j] && b[j] <= y)
c[i]++;
}
int idx[1001];
for (int i = 0; i <= 1000; i++)
idx[i] = i;
sort(idx, idx + m + 1, [&](int a, int b) {
if (c[a] != c[b])
return c[a] > c[b];
return a < b;
});
if (idx[0] == 0) {
printf("0\n");
}
else {
printf("%d\n", idx[0]);
for (int i = 1; i < m + 1; i++) {
if (c[idx[i]] != c[idx[i - 1]])
break;
printf("%d\n", idx[i]);
}
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0