QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736330#9623. 合成大西瓜ucup-team4352#RE 0ms3652kbC++23717b2024-11-12 10:08:322024-11-12 10:08:33

Judging History

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

  • [2024-11-12 10:08:33]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3652kb
  • [2024-11-12 10:08:32]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
int deg[100005];
int a[100005];
void solve(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	if(n==1){
		cout<<a[1]<<"\n";
		return;
	}
	for(int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		deg[u]++;
		deg[v]++;
	}
	vector<int>t;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(deg[i]>1)ans=max(ans,a[i]);
		else t.push_back(a[i]);
	}
	sort(t.begin(),t.end());
	t.pop_back();
	ans=max(ans,t.back());
	cout<<ans<<"\n";
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	int t=1;
	// cin>>t;
	while(t--)solve();
	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: 3652kb

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
Runtime Error

input:

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

output:


result: