QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#882220 | #10053. Post Office | guleng2007# | 13 | 379ms | 24332kb | C++20 | 1.1kb | 2025-02-04 22:21:28 | 2025-02-04 22:21:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int p[N], a[N], b[N], n, m;
namespace first
{
vector <int> vec[N*2];
bool check()
{
if(p[1]!=1)
return false;
for(int i=2;i<=n;i++)
if(p[i]!=i-1)
return false;
return true;
}
bool check(int k)
{
for(int i=1;i<=n+m+1;i++)
vec[i].clear();
for(int i=1;i<=m;i++)
{
if(a[i]>b[i]+k)
return false;
vec[min(n+m+1,b[i]+k)].push_back(a[i]);
}
priority_queue <int> q;
for(int i=n+m+1;i>=1;i--)
{
for(auto x:vec[i])
q.push(x);
if(q.size())
{
int x=q.top();
q.pop();
if(x>i)
return false;
}
}
if(q.size())
return false;
return true;
}
void work()
{
int l=0, r=n+m+1, ans=-1;
while(l<=r)
{
int mid=(l+r)/2;
if(check(mid))
ans=mid, r=mid-1;
else
l=mid+1;
}
printf("%d\n",ans);
}
}
int main()
{
cin >> n;
for(int i=1;i<=n;i++)
scanf("%d",&p[i]);
cin >> m;
for(int i=1;i<=m;i++)
scanf("%d %d",&a[i],&b[i]);
if(first::check())
{
first::work();
return 0;
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5960kb
input:
3000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...
output:
result:
wrong answer 1st lines differ - expected: '1119', found: ''
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 0ms
memory: 5964kb
input:
5 2 1 1 3 1 5 1 2 4 1 5 1 3 1 4 1
output:
result:
wrong answer 1st lines differ - expected: '3', found: ''
Subtask #3:
score: 13
Accepted
Test #34:
score: 13
Accepted
time: 94ms
memory: 21472kb
input:
2 1 1 200000 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1...
output:
200000
result:
ok single line: '200000'
Test #35:
score: 13
Accepted
time: 249ms
memory: 13324kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
200000
result:
ok single line: '200000'
Test #36:
score: 13
Accepted
time: 379ms
memory: 17664kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
200008
result:
ok single line: '200008'
Test #37:
score: 13
Accepted
time: 0ms
memory: 6224kb
input:
3000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
5998
result:
ok single line: '5998'
Test #38:
score: 13
Accepted
time: 108ms
memory: 24332kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
399998
result:
ok single line: '399998'
Test #39:
score: 13
Accepted
time: 2ms
memory: 6096kb
input:
3000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
3000
result:
ok single line: '3000'
Test #40:
score: 13
Accepted
time: 214ms
memory: 22600kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
200000
result:
ok single line: '200000'
Subtask #4:
score: 0
Wrong Answer
Test #41:
score: 25
Accepted
time: 133ms
memory: 17612kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
199401
result:
ok single line: '199401'
Test #42:
score: 25
Accepted
time: 113ms
memory: 17484kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
199604
result:
ok single line: '199604'
Test #43:
score: 0
Wrong Answer
time: 2ms
memory: 6088kb
input:
3000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
2958
result:
wrong answer 1st lines differ - expected: '-1', found: '2958'
Subtask #5:
score: 0
Wrong Answer
Test #51:
score: 0
Wrong Answer
time: 15ms
memory: 6988kb
input:
2 2 1 200000 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 2 1 2 2 1 2 1 1 2 2 1 2 1 1 2 1 2 2 1 1 2 1 2 2 1 2 1 1 2 1 2 1 2 2 1 2 1 2 1 2 1 1 2 2 1 2 1 2 1 1 2 2 1 1 2 1 2 1 2 1 2 2 1 2 1 2 1 2 1 1 2 2 1 1 2 1 2 1 2 2 1 1 2 1 2 1 2 1 2 2 1 2 1 2 1 1 2 1 2 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 1 1 2 1 2 2 1 2 1...
output:
result:
wrong answer 1st lines differ - expected: '100031', found: ''
Subtask #6:
score: 0
Wrong Answer
Test #60:
score: 0
Wrong Answer
time: 28ms
memory: 6860kb
input:
200000 1 1 1 3 3 2 5 3 4 6 9 3 3 9 14 13 4 2 18 9 3 11 20 13 7 13 14 6 13 2 22 14 5 9 19 7 28 22 10 37 37 26 15 39 18 31 18 19 22 6 4 22 29 30 43 38 33 39 19 10 14 25 35 5 3 50 34 13 60 44 31 47 67 27 52 26 48 30 18 63 76 80 49 16 39 16 59 77 60 26 84 50 54 36 75 77 72 77 1 45 13 20 86 19 56 9 47 82...
output:
result:
wrong answer 1st lines differ - expected: '119708', found: ''
Subtask #7:
score: 0
Wrong Answer
Test #97:
score: 0
Wrong Answer
time: 30ms
memory: 7500kb
input:
200000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
result:
wrong answer 1st lines differ - expected: '100667', found: ''