QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#236119 | #6703. Tokens on the Segments | stcmuyi# | WA | 228ms | 11516kb | C++20 | 1.4kb | 2023-11-03 16:39:57 | 2023-11-03 16:39:58 |
Judging History
answer
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define i64 long long
#define endl '\n'
#define lb(x) ((x) & (-x))
using namespace std;
const i64 mod = 1e15+7;
const int maxn = 1e3+10;
signed main()
{
IOS;
int t; cin >> t;
while(t--)
{
int n; cin >> n;
vector<pair<int,int>> v(n+1);
vector<int> s;
for(int i = 1; i <= n; ++i)
{
cin >> v[i].first >> v[i].second;
s.push_back(v[i].first);
s.push_back(v[i].second);
s.push_back(v[i].first - 1);
s.push_back(v[i].first + 1);
s.push_back(v[i].second - 1);
s.push_back(v[i].second + 1);
}
sort(v.begin() + 1,v.end());
sort(s.begin(),s.end());
int len = unique(s.begin(),s.end()) - s.begin();
int ans = 0,now = 1;
priority_queue<pair<int,int>> q;
for(int i = 0; i < len; ++i)
{
while(now <= n && v[now].first <= s[i])
{
q.push({-v[now].second,-v[now].first});
now++;
}
while(q.size() && -q.top().first < s[i]) q.pop();
if(q.size())
{
ans++;
q.pop();
}
}
cout << ans << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3776kb
input:
2 3 1 2 1 1 2 3 3 1 2 1 1 2 2
output:
3 2
result:
ok 2 number(s): "3 2"
Test #2:
score: -100
Wrong Answer
time: 228ms
memory: 11516kb
input:
10000 6 5 19 7 12 10 10 4 14 1 12 5 11 7 3 5 1 10 12 15 2 13 8 11 5 20 11 14 18 6 17 6 9 6 20 2 7 1 11 16 19 2 5 1 14 5 8 14 19 4 7 11 19 11 13 2 9 3 12 12 13 19 19 13 16 11 11 13 1 2 14 17 15 16 12 17 15 17 6 7 8 11 12 19 3 8 10 19 18 6 9 16 18 13 15 14 15 9 13 2 8 12 18 8 16 16 18 3 18 1 12 4 13 1...
output:
6 7 18 11 18 12 8 18 16 3 4 5 9 18 14 19 18 13 8 17 16 19 11 17 11 14 4 13 13 3 5 15 9 3 17 8 8 15 7 20 4 11 18 19 6 13 14 12 20 10 6 6 11 7 13 12 19 3 16 17 14 14 7 6 6 11 13 13 3 5 3 4 10 6 3 7 19 14 13 4 9 8 15 19 10 11 10 8 4 18 20 8 19 10 18 19 13 11 6 16 16 18 10 6 8 8 9 16 8 14 14 15 13 17 18...
result:
wrong answer 813th numbers differ - expected: '20', found: '19'