/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Time Exceeded ≥2091ms ≥532.0 KiB
#2 Time Exceeded ≥2084ms ≥320.0 KiB
#3 Time Exceeded ≥2069ms ≥320.0 KiB
#4 Time Exceeded ≥2088ms ≥532.0 KiB
#5 Time Exceeded ≥2092ms ≥532.0 KiB
#6 Time Exceeded ≥2094ms ≥324.0 KiB
#7 Time Exceeded ≥2087ms ≥324.0 KiB
#8 Time Exceeded ≥2087ms ≥320.0 KiB
#9 Time Exceeded ≥2090ms ≥320.0 KiB
#10 Time Exceeded ≥2081ms ≥320.0 KiB
#11 Time Exceeded ≥2090ms ≥532.0 KiB
#12 Time Exceeded ≥2095ms ≥532.0 KiB
#13 Time Exceeded ≥2088ms ≥324.0 KiB
#14 Time Exceeded ≥2090ms ≥576.0 KiB
#15 Time Exceeded ≥2089ms ≥740.0 KiB
#16 Time Exceeded ≥2094ms ≥744.0 KiB
#17 Time Exceeded ≥2086ms ≥1.312 MiB
#18 Time Exceeded ≥2095ms ≥568.0 KiB
#19 Time Exceeded ≥2080ms ≥776.0 KiB
#20 Time Exceeded ≥2094ms ≥780.0 KiB
#21 Time Exceeded ≥2063ms ≥784.0 KiB
#22 Time Exceeded ≥2057ms ≥792.0 KiB
#23 Time Exceeded ≥2089ms ≥800.0 KiB
#24 Time Exceeded ≥2088ms ≥784.0 KiB
#25 Time Exceeded ≥2089ms ≥800.0 KiB
#26 Time Exceeded ≥2084ms ≥800.0 KiB
#27 Time Exceeded ≥2086ms ≥812.0 KiB
#28 Time Exceeded ≥2093ms ≥820.0 KiB
#29 Time Exceeded ≥2080ms ≥560.0 KiB
#30 Time Exceeded ≥2091ms ≥1.312 MiB
#31 Time Exceeded ≥2078ms ≥1.32 MiB
#32 Time Exceeded ≥2058ms ≥580.0 KiB
#33 Wrong Answer 1511ms 1.32 MiB
#34 Time Exceeded ≥2083ms ≥740.0 KiB
#35 Time Exceeded ≥2094ms ≥1.312 MiB

Code

/*For today, you happen to be the defeated. But what will you become tomorrow?*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long int 
#define dbg if(debugg)
#define F first 
#define S second 

bool debugg = false;

template <typename T>
using order_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());  


void solve()
{
    
    int n;
    cin >> n;
    vector<int>v(n);
    for(int i = 0; i < n; i ++) cin >> v[i];


    clock_t st = clock();
    int ans = 0;
    while(clock() < st + CLOCKS_PER_SEC * 1.5){
        random_shuffle(v.begin(), v.end());
        int x = 0, y = 0, a = (n + 1) / 2, b = n / 2;
        for(int i = 0; i < n; i ++){
            if(a == 0){
                y = __gcd(y, v[i]);
                b --;
            }
            else if(b == 0){
                x = __gcd(x, v[i]);
                a --;
            }

            else{
                if(__gcd(x, v[i]) == x){
                    a --;
                }

                else{
                    y = __gcd(y, v[i]);
                    b --;
                }
            }
        }
        ans = max(ans, x + y);

    }
    cout << ans << '\n';
}



int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t  = 1;
    cin>>t;

    while(t--){

        solve();

    }

    return 0;

}

Information

Submit By
Type
Submission
Problem
P1077 Even Odd GCD (Hard Version)
Contest
Bangladesh 2.0
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 17:19:46
Judged At
2024-10-03 13:22:34
Judged By
Score
0
Total Time
≥2095ms
Peak Memory
≥1.32 MiB