QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#608405#5465. Maximum GCDHTensor#WA 10ms3856kbC++231.2kb2024-10-03 21:35:262024-10-03 21:35:26

Judging History

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

  • [2024-10-03 21:35:26]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:3856kb
  • [2024-10-03 21:35:26]
  • 提交

answer

#include <bits/stdc++.h>
#define dd(x) cout << #x << "\n"
#define d(x) cout << #x  << ": " << x << "\n"
#define SZ(x) ((int)(x).size())
using namespace std;
#define int long long
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using a3 = array<int, 3>;
using ll = long long;
const int inf = 0x3f3f3f3f3f3f3f3fLL;

// #define MULTI_TEST

void solve() {
    int n; cin >> n;
    vector<int> a(n + 1);
    int gcdv = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        gcdv = gcd(gcdv, a[i]);
    }

    int ans = gcdv;
    int minx = *min_element(a.begin() + 1, a.end());
    int canMin = 1;
    for(int i = 1; i <= n; i++) {
        if(a[i] == minx) continue;
        if(((a[i] + 1) / 2 + 1) < minx) canMin = false;
    }
    if(canMin) ans = max(ans, minx);

    int globalMin = inf;
    for(int i = 1; i <= n; i++) {
        globalMin = min(globalMin, (a[i] + 1) / 2 + 1);
    }
    ans = max(ans, globalMin);
    cout << ans <<"\n";
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
#ifdef MULTI_TEST
    int T; cin >> T;
#else
    int T = 1;
#endif
    while(T--) solve();
    return 0;
}

詳細信息

Test #1:

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

input:

3
3 10 7

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 10ms
memory: 3824kb

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: 5ms
memory: 3844kb

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:

6

result:

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