結果

問題 No.1837 Same but Different
ユーザー publfl2publfl2
提出日時 2022-02-11 22:40:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,200 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 50,024 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 04:37:02
合計ジャッジ時間 3,945 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <vector>

std::vector<int> V1[3],V2;
void func(int k, int n, int sum)
{
	for(int i=0;i<n;i++) V1[k].push_back(i), sum -= i;
	while(sum>0)
	{
		int val = sum<n?sum:n;
		for(int i=n-val;i<n;i++) V1[k][i]++;
		sum -= val;
	}
}

int main()
{
	int a;
	scanf("%d",&a);
	if(a<=70)
	{
		int S = 0;
		for(int i=0;i<a-1;i++) S -= i;
		for(int i=2*a;i<3*a;i++) S += i;
		
		for(int i=0;i<a-1;i++) printf("%d ",i);
		printf("%d\n",S);
		for(int i=2*a;i<3*a;i++) printf("%d ",i);
		return 0;
	}
	
	int C1 = a, C2 = a;
	
	int sum = 0;
	for(int i=1000;i<1000+a;i++)
	{
		sum += i;
		V2.push_back(i);
	}
	
	for(int j=0;j<=a;j++)
	{
		int s1 = j, s2 = a-j;
		if(s1<=1000 && s2<=2000)
		{
			int t = sum-s2*8000;
			int val1 = s1*(s1+1)/2 + s2*(s2+1)/2;
			int val2 = s1*(2000-s1+1)/2 + s2*(20000-s2+1)/2;
			if(val1+s2*8000<=t&&t<=val2+s2*8000)
			{
				int k1 = s1*(s1+1)/2;
				int k2 = t - s2*(s2+1)/2;
				int k3 = k1>k2?k1:k2;
				func(1,s1,k3);
				func(2,s2,t-k3);
				goto u;
			}
		}
	}
	u:;
	
	for(int i=0;i<V1[1].size();i++) printf("%d ",V1[1][i]);
	for(int i=0;i<V1[2].size();i++) printf("%d ",V1[2][i]+8000);
	printf("\n");
	for(int i=0;i<V2.size();i++) printf("%d ",V2[i]);
}
0