QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#609680#7695. Double UpxyyyWA 1ms3680kbC++171.3kb2024-10-04 13:42:462024-10-04 13:42:47

Judging History

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

  • [2024-10-04 13:42:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3680kb
  • [2024-10-04 13:42:46]
  • 提交

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'