結果

問題 No.118 門松列(2)
ユーザー kurome____kurome____
提出日時 2016-02-28 21:37:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 1,012 bytes
コンパイル時間 2,750 ms
コンパイル使用メモリ 170,220 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 14:01:03
合計ジャッジ時間 2,590 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 18 ms
5,376 KB
testcase_02 AC 17 ms
5,376 KB
testcase_03 AC 19 ms
5,376 KB
testcase_04 AC 20 ms
5,376 KB
testcase_05 AC 19 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 18 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 17 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 11 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 7 ms
5,376 KB
testcase_19 AC 10 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 15 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 14 ms
5,376 KB
testcase_24 AC 7 ms
5,376 KB
testcase_25 AC 10 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |   scanf("%d ", &n);
      |   ~~~~~^~~~~~~~~~~
main.cpp:29:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |     scanf("%d ", a+i);
      |     ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define RFOR(i,e,s) for(int (i)=(e)-1;(i)>=(int)(s);(i)--)
#define RREP(i,e) RFOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;
typedef priority_queue<int> PQI;
typedef priority_queue<PII> PQII;

const double EPS = 1e-10;
const int N = 1e5;
const ll mod = 1e9+7;
int n;
int a[N];

int main() {
  scanf("%d ", &n);
  vector<int> b(n);
  REP(i,n) {
    scanf("%d ", a+i);
    b[i] = a[i];
  }
  sort(all(b));
  b.erase(unique(all(b)), b.end());
  int m = (int)b.size();
  map<int, int> idx;
  REP(i,m) idx[b[i]] = i;
  fill(all(b), 0);
  REP(i,n) b[idx[a[i]]]++;

  ll res = 0;
  REP(i,m) FOR(j,i+1,m) FOR(k,j+1,m) {
    ll tmp = (ll)b[i];
    tmp = (tmp*b[j]) % mod;
    tmp = (tmp*b[k]) % mod;
    res = (res + tmp) % mod;
  }

  printf("%lld\n", res);

  return 0;
}
0