結果
問題 | No.742 にゃんにゃんにゃん 猫の挨拶 |
ユーザー |
![]() |
提出日時 | 2018-10-05 21:47:57 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,500 ms |
コード長 | 362 bytes |
コンパイル時間 | 538 ms |
コンパイル使用メモリ | 55,000 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 13:55:34 |
合計ジャッジ時間 | 1,162 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
#include <iostream>using namespace std;int main() {int n; cin >> n;int a[n]; for (int i = 0; i < n; i++) cin >> a[i];long long ans = 0;int bit[n+1] = {};for (int i = n-1; i >= 0; i--) {for (int x = a[i]; x > 0; x -= x&-x) ans += bit[x];for (int x = a[i]; x <= n; x += x&-x) bit[x]++;}cout << ans << endl;}