QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#546539#7695. Double UpOlegpresnyakov#WA 0ms3864kbC++201.2kb2024-09-04 08:48:042024-09-04 08:48:05

Judging History

你现在查看的是最新测评结果

  • [2024-09-04 08:48:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3864kb
  • [2024-09-04 08:48:04]
  • 提交

answer

#include <algorithm>
#include <vector>
#include <iostream>
#include <array>
#include <queue>
#include <bitset>
#include <math.h>
#include <iomanip>

using namespace std;

#define ar array
typedef long long ll;
typedef int uci;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define irep(i, a, b) for(int i = a; i > (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
#define ve vector
typedef ve<int> vi;
typedef ve<vi> vvi;
#define int long long


signed main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);


    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }

    deque<int> q;
    q.push_back(a[0]);
    for(int i = 1; i < n; ++i){
        while(q.size() >= 2 && a[i] > q.back() && q[q.size() - 2] > q.back()){
            q.pop_back();
        }

        if(a[i] == q.back()){
            int x = a[i];
            while(!q.empty() && x == q.back()){
                q.pop_back();
                x += x;
            }

            q.push_back(x);
        }

        else{
            q.push_back(a[i]);
        }
    }

    cout << q.back() << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

5
4 2 2 1 8

output:

16

result:

ok single line: '16'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3864kb

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

8

result:

wrong answer 1st lines differ - expected: '512', found: '8'