QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#1171 | #669628 | #21860. 【NOIP Round #7】冒泡排序 | nodgd | atgc | Success! | 2024-11-13 09:37:33 | 2024-11-13 09:37:33 |
Details
Extra Test:
Wrong Answer
time: 289ms
memory: 98580kb
input:
6 200000 200000 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 9 10 10 ...
output:
212845 19631 26821 970741 157593 296451 130908 169611 11735 420018 703854 120707 23073 387751 294698 20050 203637 52309 294639 351015 34080 22547 63086 20850 59048 174959 105267 379996 189384 143352 313904 150720 604197 257735 351331 287622 454767 377738 372074 388151 9822 337500 305729 15666 58878 ...
result:
wrong answer 1st lines differ - expected: '200330', found: '212845'
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#669628 | #21860. 【NOIP Round #7】冒泡排序 | atgc | 100 ✓ | 1337ms | 507508kb | C++14 | 980b | 2024-10-23 19:12:17 | 2024-11-13 15:30:15 |
answer
#include<bits/stdc++.h>
#define mid ((l+r)>>1)
using namespace std;
const int maxn = 1e6+10;
struct{int64_t sum;int cnt,ls,rs;}t[maxn*21];
int tot;
void ins(int&x,int l,int r,int p,int v){
t[++tot]=t[x];x=tot;++t[x].cnt,t[x].sum+=v;
if(l==r)return;
if(p<=mid)ins(t[x].ls,l,mid,p,v);
else ins(t[x].rs,mid+1,r,p,v);
}
int64_t get(int u,int v,int p){
if(p>=t[u].cnt)return t[u].sum;
int les=t[u].ls[t].cnt-t[v].ls[t].cnt;
return p<=les?get(t[u].ls,t[v].ls,p):
t[u].ls[t].sum-t[v].ls[t].sum+get(t[u].rs,t[v].rs,p-les);
}
int n,Q;
int a[maxn],ih[maxn],ihc;
int rt[maxn];
signed main() {
ios::sync_with_stdio(0),cin.tie(0);
cin>>n>>n>>Q;
for(int i=1;i<=n;++i)cin>>a[i],ih[i]=a[i];
sort(ih+1,ih+n+1);
for(int i=1,_;i<=n;++i)ins(rt[i]=rt[i-1],1,n,
_=lower_bound(ih+1,ih+n+1,a[i])-ih,a[i]),--ih[_];
while(Q--){
int l,r,k,x,y;cin>>l>>r>>k>>x>>y;
cout<<get(rt[min(l-1+y+k,r)],rt[l-1],y)-get(rt[min(l-1+x-1+k,r)],rt[l-1],x-1)<<'\n';
}
}