Submission #19437313


Source Code Expand

Copy
#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    for(auto&& i : A)cin >> i;
    vector<unsigned long> n(N), p(N);
    for(unsigned long i{0}, prev{numeric_limits<unsigned long>::max()}, cnt{0}; i < N; ++i){
        while(prev < A[i]){
            cnt += 2 * i;
            prev *= 4;
        }
        prev = A[i];
        n[i] = ++cnt;
    }
    for(unsigned long i{N}, prev{numeric_limits<unsigned long>::max()}, cnt{0}; i--; ){
        while(prev < A[i]){
            cnt += 2 * (N - i - 1);
            prev *= 4;
        }
        prev = A[i];
        p[i] = cnt;
    }
    n.insert(begin(n), 0);
    p.push_back(0);
    unsigned long ans{numeric_limits<unsigned long>::max()};
    for(unsigned long i{0}; i <= N; ++i)ans = min(ans, n[i] + p[i]);
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task E - Negative Doubling
User MMNMM
Language C++ (GCC 9.2.1)
Score 0
Code Size 909 Byte
Status WA
Exec Time 76 ms
Memory 9592 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 3
AC × 11
WA × 17
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt WA 8 ms 3484 KB
10.txt AC 73 ms 9528 KB
11.txt AC 71 ms 9540 KB
12.txt WA 74 ms 9348 KB
13.txt WA 73 ms 9500 KB
14.txt WA 72 ms 9404 KB
15.txt WA 75 ms 9420 KB
16.txt WA 74 ms 9416 KB
17.txt WA 70 ms 9520 KB
18.txt WA 72 ms 9488 KB
19.txt WA 68 ms 9228 KB
2.txt WA 76 ms 9592 KB
20.txt WA 73 ms 9536 KB
21.txt WA 71 ms 9496 KB
22.txt WA 74 ms 9352 KB
3.txt AC 73 ms 9424 KB
4.txt AC 73 ms 9488 KB
5.txt AC 74 ms 9536 KB
6.txt WA 72 ms 9356 KB
7.txt WA 74 ms 9540 KB
8.txt WA 69 ms 8908 KB
9.txt WA 72 ms 9416 KB
sample1.txt AC 2 ms 3624 KB
sample2.txt AC 2 ms 3416 KB
sample3.txt AC 2 ms 3628 KB