QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#871898#9232. Mathematics ChampionshipsanahartmannWA 9ms4840kbC++141.0kb2025-01-25 22:40:572025-01-25 22:40:57

Judging History

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

  • [2025-01-25 22:40:57]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:4840kb
  • [2025-01-25 22:40:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n;
    vector<ll> v;
    for (int i = 0; i < pow(2, n); i++)
    {
        cin >> m;
        v.push_back(m);
    }

    ll a, b, j = 0, k = 0;
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++)
    {
        j = 0;
        while (j < pow(2, n - i))
        {

            a = v[j + k];
            b = v[j + 1 + k];
            // cout << a << " " << b << " " << j << endl;
            if (b > a + b && b > m && b > a)
            {
                m = b;
            }
            else if (a + b > b && a + b > m && a + b > a)
            {
                m = a + b;
            }
            else if (a > b && a > m && a + b < a)
            {
                m = a;
            }

            v.push_back(a + b);
            j += 2;
        }
        k += j;
    }

    cout << m << "\n";

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3968kb

input:

2
5 -1 2 -10

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: 0
Accepted
time: 9ms
memory: 4840kb

input:

16
-609613 -130770 -74903 -953063 -673733 -7782 -141033 -99062 -498219 -788730 -18046 -531998 -902273 -849783 -790670 -400728 -647376 -304831 -612699 -804475 -583199 -556118 -210732 -764688 -261754 -909084 -204446 -122287 -599939 -883646 -162399 -604178 -457433 -86693 -599542 -859403 -144631 -541667...

output:

-32

result:

ok 1 number(s): "-32"

Test #3:

score: -100
Wrong Answer
time: 6ms
memory: 4840kb

input:

16
1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1...

output:

1111490560

result:

wrong answer 1st numbers differ - expected: '65536000000', found: '1111490560'