QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245826#7625. Pathucup-team1447#AC ✓4ms4348kbC++142.6kb2023-11-10 13:02:452023-11-10 13:02:45

Judging History

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

  • [2023-11-10 13:02:45]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:4348kb
  • [2023-11-10 13:02:45]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define mod 998244353
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
 
#define maxn 200005
#define inf 0x3f3f3f3f

int n,m,a[maxn],b[maxn];
ll res=0;

void work()
{
	n=read(),m=read();
	For(i,1,n)a[i]=read();
	For(i,1,m)b[i]=read();
	For(i,1,n-1)res+=abs(a[i]-a[i+1]);
	For(i,1,m-1)res+=abs(b[i]-b[i+1]);
	cout<<res<<"\n";
}

signed main()
{
	int T=1;
	while(T--)work();
	return 0;
}
/*

*/

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3420kb

input:

4 4
1 3 3 1
8 10 8 5

output:

11

result:

ok single line: '11'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3336kb

input:

4 2
5 7 8 10
10 3

output:

12

result:

ok single line: '12'

Test #3:

score: 0
Accepted
time: 4ms
memory: 4304kb

input:

100000 100000
18394 24233 357 52481 18043 49271 55052 81632 30068 16351 74661 71867 28721 46743 54031 18957 25470 94751 25746 62355 22561 5373 99009 49079 48551 48807 41085 90981 82649 23014 74376 54517 95181 9445 10083 85937 95809 31477 38527 68803 91671 55251 17894 43472 69255 20256 21718 38213 12...

output:

6671609257

result:

ok single line: '6671609257'

Test #4:

score: 0
Accepted
time: 4ms
memory: 4348kb

input:

100000 100000
49849 61189 44964 89719 54861 59757 54071 37516 69885 42727 69469 60593 62981 34185 36641 36826 47251 10501 71167 44261 42977 35866 72991 35233 39003 96298 75153 25421 43153 6520 11321 87601 92801 65989 74932 30242 13385 36407 76034 97112 44941 93553 41606 7201 71725 45052 75732 72300 ...

output:

6672086237

result:

ok single line: '6672086237'

Test #5:

score: 0
Accepted
time: 0ms
memory: 4124kb

input:

100000 90000
1 62782 1 26382 1 69310 1 6311 1 96861 1 14370 1 58980 1 48109 1 64865 1 5033 1 24391 1 28997 1 48373 1 13006 1 12285 1 16585 1 8426 1 27406 1 8738 1 90929 1 41126 1 71171 1 31553 1 77113 1 82309 1 75665 1 63265 1 74113 1 47691 1 8004 1 41589 1 4582 1 76800 1 67765 1 57435 1 53126 1 883...

output:

9473046647

result:

ok single line: '9473046647'

Test #6:

score: 0
Accepted
time: 3ms
memory: 4264kb

input:

90000 100000
1 29919 1 19450 1 15481 1 12155 1 22315 1 13158 1 25727 1 195 1 23167 1 18981 1 11091 1 17235 1 9448 1 11997 1 17043 1 31138 1 10513 1 23390 1 1881 1 27821 1 11028 1 26154 1 19893 1 6553 1 1936 1 32053 1 91 1 8858 1 28924 1 32233 1 26776 1 18195 1 5946 1 20077 1 12939 1 9983 1 28015 1 2...

output:

3109377821

result:

ok single line: '3109377821'

Test #7:

score: 0
Accepted
time: 3ms
memory: 4144kb

input:

90000 100000
1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000...

output:

18999610002

result:

ok single line: '18999610002'

Test #8:

score: 0
Accepted
time: 3ms
memory: 4020kb

input:

100000 90000
1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000...

output:

18999610002

result:

ok single line: '18999610002'

Test #9:

score: 0
Accepted
time: 3ms
memory: 3872kb

input:

89587 32731
8066 30223 13728 32177 24547 24078 14708 6400 2772 4833 30027 25808 32423 12769 10277 7920 20862 18932 29030 17666 14084 31337 1068 19072 28255 31011 9440 28668 19552 17402 9483 8108 13821 350 20843 29477 7938 21565 1607 18023 24835 10023 24063 31770 32405 12977 11751 22295 9918 17175 17...

output:

1337025965

result:

ok single line: '1337025965'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3492kb

input:

20906 9083
26870 17089 29290 17540 8801 26106 13969 6620 15163 22028 9916 14194 2672 6591 19430 27240 12403 30800 5800 19971 21563 21095 9307 3146 12684 1864 24445 3280 23671 14925 32597 1486 24100 3220 10970 9076 3791 7925 17106 14721 20753 28727 5943 13074 4705 27523 3038 13495 13530 15128 28763 9...

output:

328067052

result:

ok single line: '328067052'

Extra Test:

score: 0
Extra Test Passed