結果

問題 No.545 ママの大事な二人の子供
ユーザー myantamyanta
提出日時 2017-07-14 23:06:45
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 607 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 48,512 KB
実行使用メモリ 294,144 KB
最終ジャッジ日時 2024-04-16 20:39:48
合計ジャッジ時間 4,303 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 13 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 26 ms
6,912 KB
testcase_17 AC 132 ms
20,992 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |                         scanf("%lld%lld", &a[i], &b[i]);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<vector>
#include<set>
#include<cstdlib>


using namespace std;

using ll=long long;
using vll=vector<ll>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vll a(n), b(n);
		set<ll> s;

		for(int i=0;i<n;i++)
		{
			scanf("%lld%lld", &a[i], &b[i]);
		}

		s.insert(0);
		for(int i=0;i<n;i++)
		{
			auto t=s;
			s.clear();
			for(auto te:t)
			{
				s.insert(te+a[i]);
				s.insert(te-b[i]);
			}
		}

		auto it=s.begin();
		ll ans=llabs(*it);
		for(;it!=s.end();++it)
		{
			if(ans>llabs(*it))
			{
				ans=llabs(*it);
			}
		}
		printf("%lld\n", ans);
	}

	return 0;
}
0