CSES - Aalto Competitive Programming 2024 - wk8 - Homework C++ - Results
Submission details
Task:Counting ones
Sender:joaquimballester
Submission time:2024-10-26 17:56:10 +0300
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.22 sdetails
#80.22 sdetails
#90.22 sdetails
#100.22 sdetails

Code

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <functional>
#include <utility>
using namespace std;

int main(){
    int n;
    cin >> n;

    vector<long long> v(n);

    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    long long max = 0;
    pair<long,long> best_pair;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            long long u_act =__builtin_popcount(v[i] & v[j]);
            if(u_act > max){
                best_pair = make_pair(i,j);
                max = u_act;
            }
        }
    }
    cout << max <<endl;
    cout << v[best_pair.first] << ' '<<v[best_pair.second]<<endl;
}

Test details

Test 1

Verdict:

input
5
42 100 73 94 1 

correct output
9
42 73

user output
2
42 94

Test 2

Verdict:

input
5
44 19 3 94 55 

correct output
8
19 94

user output
3
19 55

Test 3

Verdict:

input
10
551 71 709 840 291 122 511 570...

correct output
15
893 438

user output
7
511 893

Test 4

Verdict:

input
10
968 901 548 173 973 856 715 61...

correct output
14
715 698

user output
5
968 973

Test 5

Verdict:

input
100
221994 55181 870733 831328 206...

correct output
29
396737 649459

user output
13
979445 981469

Test 6

Verdict:

input
100
892861 947477 331980 209407 82...

correct output
29
825210 578859

user output
11
892861 622520

Test 7

Verdict:

input
10000
76308292 227339075 779918796 3...

correct output
50
978548139 589096701

user output
23
603582459 872148991

Test 8

Verdict:

input
10000
873429404 968540665 239439572 ...

correct output
49
661547021 435157931

user output
22
935328559 801110839

Test 9

Verdict:

input
10000
10374159 364461027 501874596 4...

correct output
50
313852607 889662850

user output
21
536820699 535804638

Test 10

Verdict:

input
10000
771320644 298761159 20751947 4...

correct output
49
516789275 257079921

user output
21
534183898 533921499