結果

問題 No.1623 三角形の制作
ユーザー gorugo30
提出日時 2021-05-05 14:03:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 912 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 199,572 KB
最終ジャッジ日時 2025-01-21 07:23:33
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 TLE * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:17:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
main.cpp:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define MAXRGB 5000
int r[MAXRGB + 1], g[MAXRGB + 1], b[MAXRGB + 1];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    scanf("%d", &n);
    int x;
    for (int i = 0; i < n; i++){
        scanf("%d", &x);
        r[x]++;
    }
    for (int i = 0; i < n; i++){
        scanf("%d", &x);
        g[x]++;
    }
    for (int i = 0; i < n; i++){
        scanf("%d", &x);
        b[x]++;
    }

    long ans = 0;
    for (int i = 1; i <= MAXRGB; i++){
        if (r[i] == 0) continue;
        for (int j = 1; j <= i; j++){
            if (g[j] == 0) continue;
            for (int k = 1; k <= i; k++){
                if (i + j > k && j + k > i && k + i > j) ans += (long)r[i] * g[j] * b[k];
            }
        }
    }
    cout << ans << endl;
}
0