結果

問題 No.1060 素敵な宝箱
ユーザー kotatsugamekotatsugame
提出日時 2020-05-22 22:00:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 826 ms
コンパイル使用メモリ 77,004 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 16:48:34
合計ジャッジ時間 1,766 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 19 ms
5,376 KB
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,M;
int A[300][300];
long C[300],D[300];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<M;j++)
		{
			cin>>A[i][j];
			C[j]+=A[i][j];
		}
	}
	long X=0;
	for(int j=0;j<M;j++)X+=C[j]*C[j];
	vector<pair<long,int> >Y(N);
	for(int i=0;i<N;i++)
	{
		long Ys=0;
		for(int j=0;j<M;j++)Ys+=(C[j]-A[i][j])*(C[j]-A[i][j]);
		Y[i]=make_pair(Ys-X,i);
	}
	sort(Y.begin(),Y.end());
	for(int i=1;i<N;i+=2)
	{
		int id=Y[i].second;
		for(int j=0;j<M;j++)
		{
			C[j]-=A[id][j];
			D[j]+=A[id][j];
		}
	}
	long ans=0;
	for(int j=0;j<M;j++)ans+=C[j]*C[j]-D[j]*D[j];
	cout<<ans<<endl;
}
0