QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#139640#5405. 爬楼梯1kri#0 1ms3900kbC++14817b2023-08-14 08:50:162024-07-04 01:41:38

Judging History

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

  • [2024-07-04 01:41:38]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3900kb
  • [2023-08-14 08:50:16]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
int n,m;
int a[200005];
int l,r;
int len,c[200005];
ll work(){
	ll ans=0;
	sort(c+1,c+1+len);
	if (len&1){
		int mid=(len+1)/2;
		for (int i=mid;i<=len;i++)ans+=2*c[i];
		for (int i=1;i<mid;i++)ans-=2*c[i];
		ans-=(c[mid]+c[mid+1],3*c[mid]-c[mid-1]);
	}
	else{
		int mid=len/2;
		for (int i=mid+1;i<=len;i++)ans+=2*c[i];
		for (int i=1;i<=mid;i++)ans-=2*c[i];
		ans-=c[mid+1];
		ans+=c[mid];
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	while(m--){
		scanf("%d%d",&l,&r);
		len=0;
		for (int i=l;i<=r;i++)c[++len]=a[i];
		sort(c+1,c+1+len);
		ll ans=0;
		ans+=work();
		printf("%d\n",ans);
	}
	return 0;
} 

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3900kb

input:

10 10
323351358 540774025 513831404 171513818 162079008 234580967 887182642 765979034 329924749 677555871
2 4
1 6
8 10
2 5
1 9
4 6
9 10
2 10
1 8
8 10

output:

396202828
1530795597
524477448
1099707620
-669056779
135569108
347631122
-532087891
-852963434
524477448

result:

wrong answer 1st numbers differ - expected: '711577793', found: '396202828'

Subtask #2:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

input:

200000 200000
1 2 1 2 1 1 1 2 2 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 2 2 1 1 1 1 1 1 2 2 2 1 1 2 2 1 2 1 2 1 2 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 2 1 2 2 1 1 2 1 1 1 2 1 1 2 1 2 1 1 1 2 1 2 2 2 2 1 2 2 1 1 2 2 1 2 2 1 1 1 1 2 2 2 1 1 1 1 1 2 2 1 1 1 1 2 1 2 1 2 2 2 2 1 1 2 1 2 1 1 2 1 2 2 2 1 1 1 ...

output:

17766
92870
56732
16462
79590
3872
79674
3370
151158
52672
41424
27644
52872
33690
47896
76136
59296
75972
113274
89092
114330
48490
24112
6810
164898
10914
9738
3316
33638
1510
16344
10722
89260
87924
12710
11498
464
61810
9336
100798
59812
170450
7374
78296
10230
173826
56696
106278
7504
141524
52...

result:


Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%