QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#747870#9623. 合成大西瓜AmiyaCast#WA 0ms3540kbC++20983b2024-11-14 18:32:112024-11-14 18:32:12

Judging History

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

  • [2024-11-14 18:32:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3540kb
  • [2024-11-14 18:32:11]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define pii pair<ll, ll>
const ll inf = 2e18;
const double eps = 1e-9;
using namespace std;
#define int long long
void slv(){
    ll n, m; cin >> n >> m;
    vector<pii> a(n + 1); for(int i = 1; i <= n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    if(n == 1) {
        cout << a[1].first << endl;
        return ;
    }


    vector<int> in(n + 1);
    for(int cnm = 1, x, y; cnm <= m; ++cnm) {
        cin >> x >> y;
        in[x]++, in[y]++;
    }

    sort(a.begin(), a.end(), [&](pii x, pii y) {
        return x.first > y.first;
    });


    if(in[a[1].second] >= 2) {
        cout << a[1].first << endl;
    } else {
        cout << a[2].first << endl;
    }
}

main(){
    //ios::sync_with_stdio(0), cin.tie(0);
    int _ = 1;
    //cin >> _;
    while(_--) slv();
    return 0;
}
/*
7 7
1 1 2 3 1 2 1
1 2
2 3
1 3
2 4
2 5
5 6
5 7
 */

详细

Test #1:

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

input:

7 9
1 4 1 3 3 6 7
5 4
3 6
3 4
2 3
5 2
2 6
6 7
5 1
4 6

output:

6

result:

ok single line: '6'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3540kb

input:

5 7
1 5 3 1 4
3 5
1 3
5 1
1 4
5 4
2 4
3 2

output:

4

result:

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