QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#788448#9623. 合成大西瓜Godwang#RE 1ms5672kbC++231.2kb2024-11-27 16:59:182024-11-27 16:59:19

Judging History

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

  • [2024-11-27 16:59:19]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5672kb
  • [2024-11-27 16:59:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define endl '\n'
#define ll long long
#define pb push_back

const int N=1e6+10;

//////////////////

int n,m;

int a[N];

int d[N];

vector<int > v;

/////////////////

bool cmp(int x,int y)
{
    return x>y;
}

/////////////////

void init()
{

}

/////////////////

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   // freopen("ain2.txt","r",stdin);freopen("aout.txt","w",stdout);

    cin>>n>>m;
    multiset<int > se;
    rep(i,1,n)
    {
        cin>>a[i];
        se.insert(a[i]);
    }
    rep(i,1,m)
    {
        int x,y;
        cin>>x>>y;
        d[x]++;
        d[y]++;
    }

    if(n==1)
    {
        cout<<a[1];
        exit(0);
    }

    int ans=0;

    rep(i,1,n)
    {
        if(d[i]>=2)
        {
            ans=max(ans,a[i]);
        }
        else
        {
            v.pb(a[i]);
        }
    }
    if(v.size()>=2)
    {
        sort(v.begin(),v.end(),cmp);
    }
    ans=max(ans,min(v[0],v[1]));
    cout<<ans;

    return 0;
}

詳細信息

Test #1:

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

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: