QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#609680 | #7695. Double Up | xyyy | WA | 1ms | 3680kb | C++17 | 1.3kb | 2024-10-04 13:42:46 | 2024-10-04 13:42:47 |
Judging History
answer
#include<iostream>
#include<vector>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
using namespace std;
#define int long long
#define endl "\n"
int arr[10][10];
string add(const string &num1, const string &num2) {
int carry = 0;
string result = "";
int i = num1.size() - 1, j = num2.size() - 1;
while (i >= 0 || j >= 0 || carry) {
int digit1 = (i >= 0) ? num1[i] - '0' : 0;
int digit2 = (j >= 0) ? num2[j] - '0' : 0;
int sum = digit1 + digit2 + carry;
carry = sum / 10;
result += (sum % 10) + '0';
i--;
j--;
}
reverse(result.begin(), result.end());
return result;
}
void solve(){
int n;
cin>>n;
priority_queue<string ,vector<string>,greater<string>>q;
for(int i=1;i<=n;i++){
string t;
cin>>t;
q.push(t);
}
while((int)q.size()>1){
string a=q.top();
q.pop();
string b=q.top();
q.pop();
if(a==b){
string t=add(a,b);
q.push(t);
}
else{
q.push(b);
}
}
cout<<q.top()<<endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
5 4 2 2 1 8
output:
16
result:
ok single line: '16'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3680kb
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'