Task: | Counting ones |
Sender: | htoik |
Submission time: | 2024-10-26 18:58:55 +0300 |
Language: | C++ (C++20) |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | TIME LIMIT EXCEEDED | -- | details |
#8 | TIME LIMIT EXCEEDED | -- | details |
#9 | TIME LIMIT EXCEEDED | -- | details |
#10 | TIME LIMIT EXCEEDED | -- | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:14:19: warning: comparison of integer expressions of different signedness: 'int' and 'ull' {aka 'long long unsigned int'} [-Wsign-compare] 14 | for(int i=0; i<n; i++){ | ~^~ input/code.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'ull' {aka 'long long unsigned int'} [-Wsign-compare] 22 | for(int j=0; j<n; j++){ | ~^~ input/code.cpp:23:23: warning: comparison of integer expressions of different signedness: 'int' and 'ull' {aka 'long long unsigned int'} [-Wsign-compare] 23 | for(int i=0; i<n; i++){ | ~^~
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; int main() { ios::sync_with_stdio(0); cin.tie(0); ull n; cin >> n; vector<ull> as; for(int i=0; i<n; i++){ ull a; cin >> a; as.push_back(a); } ll maxz = -1; ull ma = -1, mb = -1; for(int j=0; j<n; j++){ for(int i=0; i<n; i++){ if(i == j) continue; ull a1 = (uint32_t)(as[i] >> 32); ull a2 = (uint32_t)as[i]; ull b1 = (uint32_t)(as[j] >> 32); ull b2 = (uint32_t)as[j]; ull p12 = a1 * b2; ull p21 = a2 * b1; ull p1 = a2 * b2; ull p2 = ((a1 * b1) << 32) + p12 + p21; ll ones = __builtin_popcount(p1) + __builtin_popcount(p1 >> 32) + __builtin_popcount(p2) + __builtin_popcount(p2 >> 32); // cout << "here: " << i << " " << j << " " << ones << "\n"; // cout << "this: " << p1 << "\n"; if(ones > maxz){ maxz = ones; ma = i; mb = j; } } } if(ma > mb) swap(ma, mb); cout << maxz << "\n" << as[ma] << " " << as[mb] << "\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
5 42 100 73 94 1 |
correct output |
---|
9 42 73 |
user output |
---|
9 42 73 |
Test 2
Verdict: ACCEPTED
input |
---|
5 44 19 3 94 55 |
correct output |
---|
8 19 94 |
user output |
---|
8 19 94 |
Test 3
Verdict: ACCEPTED
input |
---|
10 551 71 709 840 291 122 511 570... |
correct output |
---|
15 893 438 |
user output |
---|
15 893 438 |
Test 4
Verdict: ACCEPTED
input |
---|
10 968 901 548 173 973 856 715 61... |
correct output |
---|
14 715 698 |
user output |
---|
14 715 698 |
Test 5
Verdict: ACCEPTED
input |
---|
100 221994 55181 870733 831328 206... |
correct output |
---|
29 396737 649459 |
user output |
---|
29 396737 649459 |
Test 6
Verdict: ACCEPTED
input |
---|
100 892861 947477 331980 209407 82... |
correct output |
---|
29 825210 578859 |
user output |
---|
29 825210 578859 |
Test 7
Verdict: TIME LIMIT EXCEEDED
input |
---|
10000 76308292 227339075 779918796 3... |
correct output |
---|
50 978548139 589096701 |
user output |
---|
(empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
input |
---|
10000 873429404 968540665 239439572 ... |
correct output |
---|
49 661547021 435157931 |
user output |
---|
(empty) |
Test 9
Verdict: TIME LIMIT EXCEEDED
input |
---|
10000 10374159 364461027 501874596 4... |
correct output |
---|
50 313852607 889662850 |
user output |
---|
(empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
input |
---|
10000 771320644 298761159 20751947 4... |
correct output |
---|
49 516789275 257079921 |
user output |
---|
(empty) |