QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88310#5435. Clamped Sequencefzj2007WA 87ms3480kbC++141.5kb2023-03-15 20:49:072023-03-15 20:49:11

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-15 20:49:11]
  • 评测
  • 测评结果:WA
  • 用时:87ms
  • 内存:3480kb
  • [2023-03-15 20:49:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace IO{
	template<typename T>inline bool read(T &x){
		x=0;
		char ch=getchar();
		bool flag=0,ret=0;
		while(ch<'0'||ch>'9') flag=flag||(ch=='-'),ch=getchar();
		while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(),ret=1;
		x=flag?-x:x;
        return ret;
	}
	template<typename T,typename ...Args>inline bool read(T& a,Args& ...args){
	    return read(a)&&read(args...);
	}
	template<typename T>void prt(T x){
		if(x>9) prt(x/10);
		putchar(x%10+'0');
	}
	template<typename T>inline void put(T x){
		if(x<0) putchar('-'),x=-x;
		prt(x);
	}
	template<typename T>inline void put(char ch,T x){
		if(x<0) putchar('-'),x=-x;
		prt(x);
		putchar(ch);
	}
	template<typename T,typename ...Args>inline void put(T a,Args ...args){
	    put(a);
		put(args...);
	}
	template<typename T,typename ...Args>inline void put(const char ch,T a,Args ...args){
	    put(ch,a);
		put(ch,args...);
	}
	inline void put(string s){
		for(int i=0,sz=s.length();i<sz;i++) putchar(s[i]);
	}
	inline void put(const char* s){
		for(int i=0,sz=strlen(s);i<sz;i++) putchar(s[i]);
	}
}
using namespace IO;
#define N 5005
int n,d,m,w[N];
long long ans,b[N];
int main(){
	read(n,d);
	for(int i=1;i<=n;i++) read(w[i]);
	for(int k=1;k<=n;k++){
		int l=w[k],r=w[k]+d;
		for(int i=1;i<=n;i++){
			if(w[i]>r) b[i]=r;
			else if(w[i]>=l) b[i]=w[i];
			else b[i]=l; 
		}
		long long res=0;
		for(int i=2;i<=n;i++) res+=abs(b[i]-b[i-1]);
		ans=max(ans,res);
	}
	put('\n',ans);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3224kb

input:

8 3
3 1 4 1 5 9 2 6

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3404kb

input:

2 1
-1000000000 1000000000

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 2ms
memory: 3196kb

input:

2 1000000000
-1000000000 1000000000

output:

1000000000

result:

ok 1 number(s): "1000000000"

Test #4:

score: 0
Accepted
time: 37ms
memory: 3332kb

input:

5000 10000
-10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10...

output:

49990000

result:

ok 1 number(s): "49990000"

Test #5:

score: 0
Accepted
time: 36ms
memory: 3324kb

input:

5000 10000
10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 1...

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 83ms
memory: 3328kb

input:

5000 2897
8987 9710 547 6523 -4484 8892 7360 7473 -5435 8122 -1396 -9963 -1884 -5758 -2930 2867 -260 -3947 -7915 -2428 4137 -1202 -1874 7205 -2852 -6126 -9346 -8662 2294 -4453 -2430 2424 9434 -112 2906 -169 -9489 -1977 68 -9072 2785 -2258 9710 271 8817 6251 3120 4765 -8449 -6625 2617 -3931 -4024 144...

output:

7111087

result:

ok 1 number(s): "7111087"

Test #7:

score: 0
Accepted
time: 52ms
memory: 3416kb

input:

5000 6321
-5894 5183 -3582 7556 -2937 2854 -5688 1422 -7283 5712 -3719 3700 -8585 2577 -703 1839 -8871 9819 -1080 6964 -7192 1664 -9414 1863 -3638 7843 -6700 9064 -4209 7225 -2617 180 -9771 401 -3029 7485 -3877 3095 -4176 5830 -1954 8879 -9515 4671 -9834 395 -3489 6706 -5316 9004 -3536 546 -5360 686...

output:

26696461

result:

ok 1 number(s): "26696461"

Test #8:

score: 0
Accepted
time: 31ms
memory: 3300kb

input:

5000 1224
-9995 -9993 -9992 -9990 -9987 -9979 -9977 -9969 -9965 -9963 -9959 -9956 -9944 -9944 -9931 -9930 -9929 -9927 -9926 -9924 -9923 -9921 -9917 -9917 -9907 -9901 -9899 -9890 -9885 -9876 -9871 -9867 -9859 -9859 -9859 -9854 -9854 -9841 -9841 -9836 -9836 -9834 -9831 -9829 -9823 -9823 -9822 -9818 -9...

output:

1224

result:

ok 1 number(s): "1224"

Test #9:

score: 0
Accepted
time: 32ms
memory: 3412kb

input:

5000 1000000
-1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 100000...

output:

4999000000

result:

ok 1 number(s): "4999000000"

Test #10:

score: 0
Accepted
time: 36ms
memory: 3480kb

input:

5000 1000000
1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000...

output:

0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 87ms
memory: 3480kb

input:

5000 187598
115918 -727930 454749 -650387 -131030 -583797 907610 -314887 -494840 -116261 406466 734257 -410787 342451 -14930 831297 314447 -433165 -777692 -609353 -434131 518832 320933 -199305 154559 932798 930259 214168 -930213 -34688 247952 503849 21404 311008 -785124 -503509 -476434 -654305 -2049...

output:

477553294

result:

ok 1 number(s): "477553294"

Test #12:

score: -100
Wrong Answer
time: 46ms
memory: 3332kb

input:

5000 771022
-433847 99241 -927062 676808 -285169 89911 -510718 955902 -571570 492726 -139309 477186 -547729 353570 -725526 425661 -48956 239263 -322769 706571 -439634 141317 -391906 398130 -314133 863417 -600052 439135 -352487 753429 -139934 14119 -561827 258290 -54747 419167 -669228 189453 -373567 ...

output:

3125423988

result:

wrong answer 1st numbers differ - expected: '3125424072', found: '3125423988'