QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#247688#7689. Flipping Cardsucup-team1074WA 1ms5664kbC++171.5kb2023-11-11 15:31:242023-11-11 15:31:26

Judging History

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

  • [2023-11-11 15:31:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5664kb
  • [2023-11-11 15:31:24]
  • 提交

answer

#include<iostream>
#include<math.h>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<queue>
#include<string.h>
#define ll long long
using namespace std;
int mid;
int ans=0;
int n;

struct la
{
    int a;
    int b;
};
la s[300100];

void di(int i)
{
    int j=i;
    int mm[n/2],len=1,xx=0,yy=0;
    while(s[j].a<=mid&&j<=n) {

        if(s[j].b>=mid) xx++;
        else yy++;

        mm[len]=s[j].b;
        len++;
        j++;
    }
    for(int z=1;z<=xx;z++)
    {
        if(z+i==n) break; 
        mm[len] = s[z+i].a;
        len++;
    }
    len--;
    sort(mm+1,mm+1+len);

    ans = max(ans,mm[xx+yy]);
}

int nb[300010];

void solve()
{
    
    cin>>n;
    
    int xa,xb;

    for(int i=1;i<=n;i++)
    {
        cin>>xa>>xb;
        s[i].a=xa; 
        s[i].b=xb;
        nb[i]=xa;
    }
    sort(nb+1,nb+1+n);
    mid = nb[(n+1)/2];
    ans=mid;
    for(int i=1;i<=n;i++)
    {   
        if(s[i].a <= mid && s[i].b >= mid)
        {
            di(i);
            int j=i;
            while(s[j].a <= mid&&j<=n) j++;
            i=j;
        }
    }

    cout<<ans;
}




bool cmp(la xm,la ym)
{
    if(xm.a!=ym.a)
        return xm.a < ym.a;
    else
        return xm.b < ym.b;
}

int main()
{
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t;
    t=1;
    while(t>0)
    {
        t--;
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

5
3 6
5 2
4 7
6 4
2 8

output:

6

result:

ok 1 number(s): "6"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5568kb

input:

1
2 1

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Accepted
time: 1ms
memory: 5664kb

input:

1
212055293 384338286

output:

384338286

result:

ok 1 number(s): "384338286"

Test #4:

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

input:

99
749159996 323524232
125448341 365892333
481980673 143665393
394405973 44741918
687549448 513811513
287088118 385131171
11865696 666468353
449920567 373650719
671547289 116780561
41003675 671513243
351534153 507850962
374160874 985661954
222519431 600582098
987220654 704142246
856147059 37783620
1...

output:

937725164

result:

wrong answer 1st numbers differ - expected: '528957505', found: '937725164'