QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#670826#7933. Build Permutationmr_vitalikTL 50ms5512kbC++14891b2024-10-24 03:46:452024-10-24 03:46:45

Judging History

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

  • [2024-10-24 03:46:45]
  • 评测
  • 测评结果:TL
  • 用时:50ms
  • 内存:5512kb
  • [2024-10-24 03:46:45]
  • 提交

answer

#include <iostream>
#include <vector>

int main()
{
    //std::cout << "Hello World!\n";
    int n;
    std::cin >> n;
    std::vector<std::pair<int, bool>> a(n, std::pair<int, bool>(0, true));
    std::vector<int> result(n, 0);

    long long sum = 0;

    for (int i = 0; i < n; ++i) {
        std::cin >> a[i].first;
        sum += a[i].first;
    }

    if ((sum * 2) % n != 0) {
        std::cout << "-1" << std::endl;
        return 0;
    }

    long long generalSum = (sum * 2) / n;

    for (int i = 0; i < n; ++i) {
        int firstNum = a[i].first;
        for (int j = 0; j < n; ++j) {
            if (a[j].second && (firstNum + a[j].first) == generalSum) {
                //result[i] = a[j].first;
                a[j].second = false;
                std::cout << j + 1 << ' ';
            }
        }
    }

    //for (int i = 0; i)


}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
4 2 5 1 3

output:

2 1 4 3 5 

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

3
2 2 3

output:

-1

result:

ok 

Test #3:

score: 0
Accepted
time: 50ms
memory: 5512kb

input:

199528
581552649 419782901 924554494 589802859 878336763 659984178 419820729 521791999 956262027 523946290 442086405 808419260 875183942 860794919 584899704 494193909 687014591 794119827 641706288 734029639 795387770 803653459 889799156 455122734 655375888 757642629 427654115 987811208 593072829 584...

output:

-1

result:

ok 

Test #4:

score: -100
Time Limit Exceeded

input:

199680
774760412 315033238 665140012 402128528 221827348 923752357 281703052 551555739 483983889 622621809 949928382 909484599 413397988 424613137 353323926 392255354 551928848 464853065 860603765 618364501 423106762 752293338 551415838 898671881 969815739 150102831 644806419 333507443 379455235 981...

output:

73439 148005 8648 89423 141979 147470 141410 69725 40153 63979 78432 103327 181609 135195 105239 127546 32464 34284 174446 34920 30629 168594 168530 161118 93855 108316 180454 174923 1995 85530 196615 98831 140833 5779 144616 158480 4431 142576 165252 72206 116180 122123 113985 60323 86875 40860 134...

result: