QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#18807 | #1877. Matryoshka Dolls | Lcyanstars | Compile Error | / | / | C | 490b | 2022-01-27 13:55:09 | 2022-05-18 04:05:17 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-05-18 04:05:17]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-01-27 13:55:09]
- 提交
answer
#include <bits/stdc++.h>
int idx[500050],a[500050],b[500050];
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i <= n;i++)
{
scanf("%d",a+i);
b[i]=a[i],idx[a[i]]=i;
}
for(int i=0;i<m;i++)
{
int l,r;
scanf("%d%d",&l,&r);
std::stable_sort(b+l,b+r+1);
long long res=0;
for(int j=l;j<r;j++)
{
res += abs(idx[b[j]]-idx[b[j+1]]);
b[j]=a[j];
}
b[r]=a[r];
printf("%lld\n",res);
}
return 0;
}
/*
5 2
5 4 2 3 1
3 4
2 5
*/
详细
answer.code:1:10: fatal error: bits/stdc++.h: No such file or directory #include <bits/stdc++.h> ^~~~~~~~~~~~~~~ compilation terminated.