QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#676976#5465. Maximum GCDjirimonWA 36ms4092kbC++17730b2024-10-26 07:38:462024-10-26 07:38:46

Judging History

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

  • [2024-10-26 07:38:46]
  • 评测
  • 测评结果:WA
  • 用时:36ms
  • 内存:4092kb
  • [2024-10-26 07:38:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    sort(arr, arr + n);

    vector<int> freq;
    for (int i = n-2; i >= 0; i--)
    {
        int diff = abs({arr[i+1]-arr[i]});
        freq.push_back(diff);

        if(i == 0) freq.push_back(arr[i]);
    }
    
    sort(freq.begin(), freq.end(), greater<int>());
    for (int i = 0; i < freq.size(); i++)
    {
        if(freq.size() == 1) {
            cout<<freq[i]<<endl;
            break;
        }
        
        if(i < freq.size()-1 && freq[i] == freq[i+1]) {
            cout<<freq[i]<<endl;
            break;
        }
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3 10 7

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Wrong Answer
time: 36ms
memory: 4092kb

input:

100000
154183567 764881828 59831034 828193326 391773598 487722171 451196811 245718514 750259573 762740115 821999084 28801227 218042831 918898632 881477122 891010192 55732830 509020430 594855913 455478382 456571462 705949609 471532655 550005603 861581472 984465652 883456918 463213251 626620153 371990...

output:

61776

result:

wrong answer 1st numbers differ - expected: '3772', found: '61776'