結果
問題 | No.2300 Substring OR Sum |
ユーザー | NAMIDAIRO |
提出日時 | 2023-05-12 21:29:57 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 1,040 bytes |
コンパイル時間 | 926 ms |
コンパイル使用メモリ | 114,504 KB |
実行使用メモリ | 4,896 KB |
最終ジャッジ日時 | 2023-08-19 03:56:10 |
合計ジャッジ時間 | 3,406 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,384 KB |
testcase_01 | AC | 2 ms
4,384 KB |
testcase_02 | AC | 2 ms
4,384 KB |
testcase_03 | AC | 29 ms
4,384 KB |
testcase_04 | AC | 25 ms
4,380 KB |
testcase_05 | AC | 30 ms
4,380 KB |
testcase_06 | AC | 17 ms
4,384 KB |
testcase_07 | AC | 93 ms
4,896 KB |
testcase_08 | AC | 38 ms
4,380 KB |
testcase_09 | AC | 32 ms
4,384 KB |
testcase_10 | AC | 76 ms
4,384 KB |
testcase_11 | AC | 88 ms
4,380 KB |
testcase_12 | AC | 96 ms
4,708 KB |
testcase_13 | AC | 77 ms
4,540 KB |
testcase_14 | AC | 30 ms
4,536 KB |
testcase_15 | AC | 41 ms
4,380 KB |
testcase_16 | AC | 73 ms
4,384 KB |
testcase_17 | AC | 93 ms
4,580 KB |
testcase_18 | AC | 1 ms
4,380 KB |
testcase_19 | AC | 1 ms
4,384 KB |
testcase_20 | AC | 1 ms
4,384 KB |
testcase_21 | AC | 1 ms
4,388 KB |
testcase_22 | AC | 1 ms
4,384 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <map> #include <queue> #include <set> #include <random> #include <iomanip> #include <string> #include <cmath> #include <complex> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) template<class T> using vi = vector<T>; template<class T> using vii = vector<vi<T>>; template<class T> using viii = vector<vii<T>>; using P = pair<ll, int>; void chmin(ll & x, ll y) { x = min(x, y); } void chmax(ll& x, ll y) { x = max(x, y); } int main() { ll n; cin >> n; vi<ll> a(n); rep(i, n) cin >> a[i]; ll ans = 0; const int mx = 28; rep(i, mx) { ll cnt = 0; ans += (1LL << i) * n * (n + 1) / 2; rep(j, n) { if (a[j] >> i & 1) { ans -= (1LL << i) * cnt * (cnt + 1) / 2; cnt = 0; } else cnt++; } if (cnt) ans -= (1LL << i) * cnt * (cnt + 1) / 2; } cout << ans << endl; return 0; }