Submission #60736758
Source Code Expand
Copy
#include <iostream>#include <vector>#include <unordered_map>using namespace std;const int MAX_VAL = 20000000;vector<int> precompute_f() {vector<int> f(MAX_VAL + 1);for (int i = 1; i <= MAX_VAL; ++i) {int x = i;while (x % 2 == 0) {x /= 2;}f[i] = x;}return f;}int main() {int N;cin >> N;vector<int> A(N);for (int i = 0; i < N; ++i) {
#include <iostream> #include <vector> #include <unordered_map> using namespace std; const int MAX_VAL = 20000000; vector<int> precompute_f() { vector<int> f(MAX_VAL + 1); for (int i = 1; i <= MAX_VAL; ++i) { int x = i; while (x % 2 == 0) { x /= 2; } f[i] = x; } return f; } int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } vector<int> f = precompute_f(); unordered_map<int, long long> freq; for (int i = 0; i < N; ++i) { freq[A[i]]++; } long long result = 0; for (auto &[x, count1] : freq) { for (auto &[y, count2] : freq) { if (x > y) continue; int sum = x + y; if (sum <= MAX_VAL) { long long f_sum = f[sum]; if (x == y) { result += f_sum * count1 * (count1 + 1) / 2; } else { result += f_sum * count1 * count2; } } } } cout << result << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Double Sum 2 |
User | BagginWithBaggin |
Language | C++ 20 (gcc 12.2) |
Score | 0 |
Code Size | 1146 Byte |
Status | TLE |
Exec Time | 4422 ms |
Memory | 91508 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 54 ms | 81300 KB |
00_sample_01.txt | AC | 54 ms | 81316 KB |
00_sample_02.txt | AC | 55 ms | 81436 KB |
01_handmade_00.txt | AC | 96 ms | 82092 KB |
01_handmade_01.txt | AC | 101 ms | 82004 KB |
01_handmade_02.txt | AC | 102 ms | 82076 KB |
01_handmade_03.txt | AC | 75 ms | 81840 KB |
02_random_00.txt | TLE | 4419 ms | 91392 KB |
02_random_01.txt | TLE | 4419 ms | 91416 KB |
02_random_02.txt | TLE | 4422 ms | 91460 KB |
02_random_03.txt | TLE | 4419 ms | 91440 KB |
02_random_04.txt | TLE | 4422 ms | 91492 KB |
02_random_05.txt | AC | 83 ms | 81564 KB |
02_random_06.txt | TLE | 4419 ms | 91492 KB |
02_random_07.txt | TLE | 4419 ms | 91480 KB |
02_random_08.txt | TLE | 4419 ms | 91508 KB |
02_random_09.txt | TLE | 4419 ms | 91416 KB |
02_random_10.txt | TLE | 4419 ms | 91460 KB |
02_random_11.txt | TLE | 4419 ms | 91408 KB |
02_random_12.txt | TLE | 4419 ms | 91436 KB |
02_random_13.txt | AC | 94 ms | 82092 KB |
02_random_14.txt | AC | 94 ms | 82096 KB |
02_random_15.txt | AC | 96 ms | 82072 KB |
02_random_16.txt | AC | 93 ms | 82004 KB |