結果

問題 No.1623 三角形の制作
ユーザー msm1993msm1993
提出日時 2021-07-28 10:59:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 615 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 1,770 ms
コンパイル使用メモリ 169,752 KB
実行使用メモリ 5,516 KB
最終ジャッジ日時 2023-10-11 05:36:18
合計ジャッジ時間 13,027 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
4,352 KB
testcase_01 AC 46 ms
4,352 KB
testcase_02 AC 521 ms
4,404 KB
testcase_03 AC 518 ms
4,348 KB
testcase_04 AC 516 ms
4,352 KB
testcase_05 AC 615 ms
5,380 KB
testcase_06 AC 394 ms
4,352 KB
testcase_07 AC 519 ms
4,376 KB
testcase_08 AC 396 ms
4,352 KB
testcase_09 AC 513 ms
4,392 KB
testcase_10 AC 573 ms
4,928 KB
testcase_11 AC 531 ms
4,528 KB
testcase_12 AC 228 ms
4,348 KB
testcase_13 AC 230 ms
4,352 KB
testcase_14 AC 228 ms
4,348 KB
testcase_15 AC 315 ms
5,500 KB
testcase_16 AC 317 ms
5,516 KB
testcase_17 AC 331 ms
5,320 KB
testcase_18 AC 334 ms
5,328 KB
testcase_19 AC 252 ms
4,352 KB
testcase_20 AC 45 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int MAX = 3001;
int main(){
  int n;
  cin >> n;
  vector<int> r(n);
  for (int i = 0; i < n; i++){
    cin >> r[i];
  }
  vector<int> g(n);
  for (int i = 0; i < n; i++){
    cin >> g[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }
  vector<int> rc(MAX, 0);
  for (int i = 0; i < n; i++){
    rc[r[i]]++;
  }
  vector<int> gc(MAX, 0);
  for (int i = 0; i < n; i++){
    gc[g[i]]++;
  }
  sort(b.begin(), b.end());
  long long ans = 0;
  for (int i = 0; i < MAX; i++){
    for (int j = 0; j <= i; j++){
      int l = upper_bound(b.begin(), b.end(), i - j) - b.begin();;
      int r = upper_bound(b.begin(), b.end(), i) - b.begin();
      ans += (long long) rc[i] * gc[j] * (r - l);
    }
  }
  cout << ans << endl;
}
0