QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#510701 | #7695. Double Up | 122 | WA | 0ms | 3840kb | C++14 | 667b | 2024-08-09 11:16:01 | 2024-08-09 11:16:01 |
Judging History
answer
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#define int long long
#define INF 0x3f3f3f3f
#define inf 1e9
signed main() {
IOS;
int n;
cin>>n;
stack<int>s;
for(int i=1;i<=n;i++)
{
int num;
cin>>num;
s.push(num);
}
stack<int>ss;
int ans=0;
while(!s.empty())
{
int num=s.top();
s.pop();
if(ss.empty()) ss.push(num);
else{
while(!ss.empty()&&ss.top()<num)
ss.pop();
while(ss.size()&&ss.top()==num)
ss.pop(),num*=2;
ss.push(num);
}
}
while(ss.size())
ans=max(ans,ss.top()),ss.pop();
cout<<ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
5 4 2 2 1 8
output:
16
result:
ok single line: '16'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3624kb
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:
512
result:
ok single line: '512'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3840kb
input:
1000 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650...
output:
0
result:
wrong answer 1st lines differ - expected: '649037107316853453566312041152512', found: '0'