/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 24ms 592.0 KiB
#3 Wrong Answer 22ms 564.0 KiB
#4 Wrong Answer 21ms 536.0 KiB
#5 Wrong Answer 22ms 676.0 KiB
#6 Wrong Answer 23ms 2.078 MiB
#7 Wrong Answer 23ms 2.082 MiB
#8 Wrong Answer 22ms 2.066 MiB
#9 Wrong Answer 21ms 2.082 MiB
#10 Wrong Answer 20ms 2.082 MiB
#11 Wrong Answer 19ms 1.918 MiB
#12 Wrong Answer 18ms 2.066 MiB
#13 Wrong Answer 17ms 2.066 MiB
#14 Wrong Answer 16ms 2.066 MiB
#15 Wrong Answer 15ms 2.082 MiB
#16 Accepted 15ms 2.078 MiB
#17 Wrong Answer 8ms 840.0 KiB
#18 Wrong Answer 6ms 592.0 KiB
#19 Accepted 7ms 872.0 KiB
#20 Accepted 24ms 2.066 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];
    vector<int>p = {0, 1, 2};
    int ans = LLONG_MAX;
    for(int itr = 0; itr < 6; itr ++){
        int cur = 0;
        for(int j = 0; j < n; j ++){
            cur += p[j % 3] * v[j];
        }
        ans = min(ans, cur);
        next_permutation(p.begin(), p.end());
    }

    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
P1087 Face the monsters
Contest
Brain Booster #5
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-05 16:48:12
Judged At
2024-10-03 13:06:04
Judged By
Score
20
Total Time
24ms
Peak Memory
2.082 MiB