QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#522727#5465. Maximum GCDxuanbac05WA 12ms4004kbC++141.3kb2024-08-17 12:48:192024-08-17 12:48:19

Judging History

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

  • [2024-08-17 12:48:19]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:4004kb
  • [2024-08-17 12:48:19]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define endl '\n'
#define MASK(i) (1LL << (i))
#define ull unsigned long long
#define ld long double
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define BIT(x , i) ((x >> (i)) & 1)
#define TASK "task"
#define sz(s) (int) (s).size()
 
using namespace std;
const int mxN = 5e5 + 227;
const int inf = 1e9 + 277;
const int mod = 1e9 + 7;
const ll infll = 1e18 + 7;
const int base = 307;
const int LOG = 20;
 
template <typename T1, typename T2> bool minimize(T1 &a, T2 b) {
    if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maximize(T1 &a, T2 b) {
    if (a < b) {a = b; return true;} return false;
}
 
int n;
int a[mxN];
 
void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + 1 + n);

    bool ok = true;
    for(int i = 2; i <= n; i++) {
        if(max(1, (a[i] - 1) / 2) < a[1]) ok = false;
    }

    cout << (ok == true ? a[1] : max(1, (a[1] - 1) / 2)) << endl;
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // freopen(TASK".inp" , "r" , stdin);
    // freopen(TASK".out" , "w" , stdout);
 
    int tc = 1;
    //cin >> tc;
    while(tc--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3 10 7

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 12ms
memory: 4004kb

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:

3772

result:

ok 1 number(s): "3772"

Test #3:

score: -100
Wrong Answer
time: 7ms
memory: 4000kb

input:

100000
80 88 53 77 74 63 57 71 75 74 27 14 38 23 24 75 33 89 81 33 100 56 53 77 55 54 63 80 100 15 70 24 100 65 95 22 34 12 31 30 83 20 68 87 23 53 53 55 72 13 57 94 27 94 93 81 96 57 11 81 18 53 34 67 77 65 38 45 45 33 66 47 56 61 60 55 13 61 60 83 24 68 88 50 59 44 27 99 22 82 16 96 62 60 98 48 78...

output:

4

result:

wrong answer 1st numbers differ - expected: '5', found: '4'