QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#373762#7689. Flipping Cardsarnold518WA 1ms3936kbC++17821b2024-04-02 04:48:162024-04-02 04:48:16

Judging History

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

  • [2024-04-02 04:48:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3936kb
  • [2024-04-02 04:48:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 3e5;

int N;
pii A[MAXN+10];
int dp[MAXN+10];

int solve(int X)
{
    int val=0, ans=0;
    for(int i=1; i<=N; i++)
    {
        val+=(A[i].first>=X);
        dp[i]=max(dp[i-1]+(A[i].second>=X), val);
    }
    val=0;
    for(int i=1; i<=N; i++)
    {
        ans=max(ans, dp[i]+val);
        val+=(A[i].first>=X);
    }
    ans=max(ans, val);
    return ans>=(N+1)/2;
}

int main()
{
    scanf("%d", &N);
    for(int i=1; i<=N; i++) scanf("%d%d", &A[i].first, &A[i].second);

    int lo=1, hi=1e9+1;
    while(lo+1<hi)
    {
        int mid=lo+hi>>1;
        if(solve(mid)) lo=mid;
        else hi=mid;
    }
    printf("%d\n", lo);
}

详细

Test #1:

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

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: 3924kb

input:

1
2 1

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

input:

1
212055293 384338286

output:

384338286

result:

ok 1 number(s): "384338286"

Test #4:

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

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:

753170802

result:

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