QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#242538#7689. Flipping CardshHap#WA 1ms5720kbC++20937b2023-11-07 14:55:232023-11-07 14:55:23

Judging History

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

  • [2023-11-07 14:55:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5720kb
  • [2023-11-07 14:55:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int N = 2e6 + 10;
int a[N], b[N];
void solve()
{
    int n;
    cin >> n;
    vector<int> tmp;
    int res1 = 0, res2 = 0;
    int p1 = 0, p2 = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
        if (a[i] >= b[i])
            res1++;
        else
        {
            res2++;
            if (!p1)
                p1 = i;
            p2 = i;
        }
    }
    if (res1 >= res2)
    {
        sort(a + 1, a + 1 + n);
        cout << a[n + 1 >> 1];
    }
    else
    {
        for (int i = p1; i <= p2; i++)
        {
            a[i] = b[i];
        }
        sort(a + 1, a + 1 + n);
        cout << a[n + 1 >> 1];
    }
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0ms
memory: 5660kb

input:

1
2 1

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

input:

1
212055293 384338286

output:

384338286

result:

ok 1 number(s): "384338286"

Test #4:

score: -100
Wrong Answer
time: 1ms
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:

459542270

result:

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