QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#418418#7695. Double Uphaze#WA 0ms3796kbC++231.7kb2024-05-23 13:46:062024-05-23 13:46:07

Judging History

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

  • [2024-05-23 13:46:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3796kb
  • [2024-05-23 13:46:06]
  • 提交

answer

/*

Author: Haze

2024/5/23

*/

#include <bits/stdc++.h>

#define irep(i, l, r) for(int i = (l); i <= (r); ++ i)
#define drep(i, r, l) for(int i = (r); i >= (l); -- i)
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr);
using namespace std;
typedef __int128 ll;

inline __int128 read() {
    __int128 s = 0;
    bool fl = false;
    char ch = (char) getchar();
    while (!isdigit(ch)) {
        if (ch == '-')fl = true;
        ch = (char) getchar();
    }
    while (isdigit(ch)) {
        s = s * 10 + (ch ^ 48);
        ch = (char) getchar();
    }
    return fl ? -s : s;
}

void print(__int128 S){
    if(S){
        print(S / 10);
        cout << (int)(S % 10);
    }
}

const int mod = 1000000000 + 7;
const int itinf = 1000000999;
const ll llinf = 2e18;
const int N = 500099;

void solve() {
    int n;
    cin >> n;
    vector<ll>s;
    irep(i, 1, n){
        ll x = read();
        if(s.size() == 0)s.push_back(x);
        else{
            bool ok = 0;
            while(s.size()){
                if(s.back() < x){
                    s.pop_back();
                }
                else{
                    if(s.back() == x){
                        s.pop_back();
                        ok = 1;
                        break;
                    }
                    else{
                        break;
                    }
                }
            }
            if(ok){
                s.push_back(x);
                auto it = std::lower_bound(s.begin(), s.end(),x);
                *it *= 2;
            }
            else s.push_back(x);
        }
    }
    print(s[0]);
}

int main() {
    // IOS
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
4 2 2 1 8

output:

16

result:

ok single line: '16'

Test #2:

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

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:

-1-70-1-4-1-1-8-3-4-60-4-6-9-2-3-1-7-3-1-6-8-7-30-3-7-1-5-8-8-4-10-5-7-2-8

result:

wrong answer 1st lines differ - expected: '512', found: '-1-70-1-4-1-1-8-3-4-60-4-6-9-2...8-7-30-3-7-1-5-8-8-4-10-5-7-2-8'