Submission #60749428


Source Code Expand

// #undef LOCAL
#ifdef LOCAL
// #define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <array>
#include <random>
#include <cassert>
#include <chrono>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/priority_queue.hpp>
using namespace std;
#ifdef LOCAL
#include "D:\c++\Algo\Debug.h"
#define print(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#else
#define debug(...) (void)0
#define dbg(a, l, r) (void)0
#define print(fmt, ...) (void)0
#endif
bool Mbg;
namespace Anonyme {
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define QwQ01AwA return 0
#define mset(a, x) memset(begin(a), x, sizeof(a))
#define mcpy(a, b) memcpy(begin(a), begin(b), sizeof(a))
#define range(a, l, r) begin(a) + l, begin(a) + r + 1
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
#define file(x) freopen(x ".in", "r", stdin), freopen(x ".out", "w", stdout)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using d32 = double;
using d64 = long double;
using pii = pair<int, int>;
template <class T> using vc = vector<T>;
template <class T> using pq = priority_queue<T>;
template <class T> using rpq = priority_queue<T, vector<T>, greater<T>>;
template <class T, int siz> using ar = array<T, siz>;
template <class T, class U> inline bool ckmax(T &x, U &&y) {return x < y ? (x = y, 1) : 0;}
template <class T, class U> inline bool ckmin(T &x, U &&y) {return x > y ? (x = y, 1) : 0;}
const int inf32 = 0x3f3f3f3f;
const i64 inf64 = 0x3f3f3f3f3f3f3f3f;

void main01() {
	#ifdef LOCAL
	file("");
	#endif
	cin.tie(nullptr) -> sync_with_stdio(false);
	int n;
	cin >> n;
	vc<int> a(n);
	for (auto &x : a) cin >> x;
	i64 ans = 0;
	for (auto &x : a) {
		ans += 1ll * x * (n - 1);
		ans += x / (1 << __builtin_ctz(x));
	}
	debug(ans);
	unordered_map<int, i64> mp, cnt;
	for (int i = 1; i <= 24; i++) {
		mp.clear(), cnt.clear();	
		int v;
		i64 res = 0;
		for (auto &x : a) {
			v = x & ((1 << i) - 1);
			v = (1 << i) - v;
			if (v == (1 << i)) v = 0;
			if (cnt.count(v)) {
				res += mp[v];
				res += cnt[v] * x;
			}
			v = (1 << i) - v;
			if (v == (1 << i)) v = 0;
			mp[v] += x, cnt[v]++;
		}
		debug(res);
		ans -= res / (1 << i);
	}
	cout << ans << '\n';
}}
bool Med;
signed main() {
	Anonyme::main01();
	#ifdef LOCAL
	cerr << endl;
	cerr << "\033[0m\033[0;32m" "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n" "\033[0m";
	cerr << "\033[0m\033[0;33m" "Memory: " << abs(&Mbg - &Med) / 1048576.0 << "mb\n" "\033[0m";
	#endif
	QwQ01AwA;
}

Submission Info

Submission Time
Task F - Double Sum 2
User Anonyme
Language C++ 20 (gcc 12.2)
Score 500
Code Size 3077 Byte
Status AC
Exec Time 391 ms
Memory 21784 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 24
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 1 ms 3632 KiB
00_sample_01.txt AC 1 ms 3504 KiB
00_sample_02.txt AC 1 ms 3632 KiB
01_handmade_00.txt AC 89 ms 3792 KiB
01_handmade_01.txt AC 66 ms 3968 KiB
01_handmade_02.txt AC 55 ms 3848 KiB
01_handmade_03.txt AC 40 ms 3568 KiB
02_random_00.txt AC 383 ms 21652 KiB
02_random_01.txt AC 385 ms 21684 KiB
02_random_02.txt AC 385 ms 21628 KiB
02_random_03.txt AC 388 ms 21632 KiB
02_random_04.txt AC 384 ms 21644 KiB
02_random_05.txt AC 43 ms 3656 KiB
02_random_06.txt AC 338 ms 21472 KiB
02_random_07.txt AC 343 ms 21720 KiB
02_random_08.txt AC 391 ms 21612 KiB
02_random_09.txt AC 391 ms 21668 KiB
02_random_10.txt AC 385 ms 21504 KiB
02_random_11.txt AC 387 ms 21784 KiB
02_random_12.txt AC 383 ms 21688 KiB
02_random_13.txt AC 119 ms 3908 KiB
02_random_14.txt AC 117 ms 4024 KiB
02_random_15.txt AC 131 ms 3968 KiB
02_random_16.txt AC 146 ms 3912 KiB