QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#478249#4393. Snatch Grocerieshorzward#WA 37ms4372kbC++17898b2024-07-14 19:38:442024-07-14 19:38:45

Judging History

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

  • [2024-07-14 19:38:45]
  • 评测
  • 测评结果:WA
  • 用时:37ms
  • 内存:4372kb
  • [2024-07-14 19:38:44]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define fastio ios::sync_with_stdio(0), cin.tie(0)

using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i].second >> v[i].first;
    }
    if(n == 1) {
        cout << "1\n";
        return;
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(i == 0 && v[i].first < v[i + 1].second) ans++;
        else if(i == n - 1 && v[i].second > v[i - 1].first) ans++;
        else {
            if(v[i].second > v[i - 1].first && v[i].first < v[i + 1].second) ans++;
        }
    }
    cout << ans << '\n';
    return;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 37ms
memory: 4372kb

input:

5
3
1 2
3 4
5 6
3
1 2
3 4
4 5
100000
263324740 263324748
920719069 920719077
82595123 82595132
765796214 765796222
621714954 621714959
77799324 77799332
278166427 278166428
375391536 375391545
856576804 856576812
512542774 512542781
829984452 829984457
302442403 302442404
779239984 779239986
1189173...

output:

3
1
99890
99868
10000

result:

wrong answer 3rd lines differ - expected: '275', found: '99890'