結果

問題 No.2239 Friday
コンテスト
ユーザー ttkkggww
提出日時 2023-03-10 21:34:32
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 914µs
コード長 530 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,001 ms
コンパイル使用メモリ 275,384 KB
実行使用メモリ 9,844 KB
最終ジャッジ日時 2026-10-15 13:59:52
合計ジャッジ時間 4,553 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int a,b;

void solve(){
	int ans = a+b;
	for(int i = 0;i<a+b;i++){
		vector<int> isa(a+b);
		for(int j = 0;j<a;j++){
			isa[(i+j)%(a+b)] = 1;
		}
		int w = 0,c = 0;
		for(int j = 0;j<(a+b);j++){
			if((j<b&&isa[j])||(j>=b)&&isa[j]==0){
				c++;
			}else{
				w++;
			}
		}
		ans = min(ans,abs(w-c));
	}
	cout<<ans<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> a >> b;
	solve();
}
0