結果

問題 No.1919 Many Monster Battles
ユーザー 👑 kmjpkmjp
提出日時 2022-05-06 11:35:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 1,591 bytes
コンパイル時間 4,623 ms
コンパイル使用メモリ 207,956 KB
実行使用メモリ 27,800 KB
最終ジャッジ日時 2023-09-19 00:42:17
合計ジャッジ時間 9,446 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 3 ms
4,384 KB
testcase_07 AC 3 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 219 ms
27,332 KB
testcase_14 AC 217 ms
27,312 KB
testcase_15 AC 217 ms
27,332 KB
testcase_16 AC 218 ms
27,388 KB
testcase_17 AC 217 ms
27,356 KB
testcase_18 AC 207 ms
27,340 KB
testcase_19 AC 209 ms
27,492 KB
testcase_20 AC 208 ms
27,340 KB
testcase_21 AC 207 ms
27,372 KB
testcase_22 AC 206 ms
27,800 KB
testcase_23 AC 217 ms
27,368 KB
testcase_24 AC 220 ms
27,388 KB
testcase_25 AC 217 ms
27,324 KB
testcase_26 AC 221 ms
27,384 KB
testcase_27 AC 191 ms
27,376 KB
testcase_28 AC 191 ms
27,348 KB
testcase_29 AC 191 ms
27,392 KB
testcase_30 AC 193 ms
27,340 KB
testcase_31 AC 215 ms
27,372 KB
testcase_32 AC 215 ms
27,352 KB
testcase_33 AC 182 ms
27,324 KB
testcase_34 AC 190 ms
27,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
vector<ll> A,B,MA,MB,M1A,M1B;
const ll mo=1000000007;
const ll M=1000000000;

ll hoge(vector<ll> A,vector<ll> B) {
	vector<ll> X,Y;
	int i;
	FOR(i,A.size()) {
		X.push_back(A[i]+B[i]);
		Y.push_back(A[i]-B[i]);
	}
	sort(ALL(X));
	sort(ALL(Y));
	ll ret=0;
	int num=0;
	ll sum=0;
	FORR(x,X) {
		x=(x%mo+mo)%mo;
		(ret+=num*x-sum)%=mo;
		(sum+=x)%=mo;
		num++;
	}
	num=sum=0;
	FORR(x,Y) {
		x=(x%mo+mo)%mo;
		(ret+=num*x-sum)%=mo;
		(sum+=x)%=mo;
		num++;
	}
	return (ret%mo+mo)%mo;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>x;
		MA.push_back(M*x);
		M1A.push_back((M+1)*x);
	}
	FOR(i,N) {
		cin>>x;
		MB.push_back(M*x);
		M1B.push_back((M+1)*x);
	}
	cout<<(hoge(M1A,M1B)-hoge(MA,M1B)+mo)%mo<<" "<<(hoge(M1A,M1B)-hoge(M1A,MB)+mo)%mo<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0