結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー akun0716akun0716
提出日時 2020-09-22 19:31:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,788 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 83,024 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-08 16:46:44
合計ジャッジ時間 2,728 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 12 ms
4,376 KB
testcase_25 AC 12 ms
4,376 KB
testcase_26 AC 13 ms
4,376 KB
testcase_27 AC 13 ms
4,380 KB
testcase_28 AC 14 ms
4,376 KB
testcase_29 AC 12 ms
4,376 KB
testcase_30 WA -
testcase_31 AC 12 ms
4,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 14 ms
4,380 KB
testcase_37 AC 14 ms
4,380 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 13 ms
4,376 KB
testcase_42 WA -
testcase_43 AC 11 ms
4,376 KB
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	VI A(N);
	int s, t; cin >> s >> t;
	s--, t--;
	REP(i, N)cin >> A[i];
	int X = 0, Y = 0;
	int ma = 0, mi = INF;
	REP(i, N) {
		int ds = min({ abs(i - s), abs(s + N - i), abs(s - N - i) });
		int dt = min({ abs(i - t), abs(t + N - i), abs(t - N - i) });
		//cout << i << " " << ds << " " << dt << endl;
		if (ds < dt)X += A[i];
		else if (dt < ds)Y += A[i];
		else {
			chmax(ma, A[i]);
			chmin(mi, A[i]);
		}
	}
	if (((N - 2) / 2) % 2 == 1) {
		if (Y > X)swap(X, Y);
		X += ma;
		Y += mi;
	}
	else {
		X += ma;
	}
	//cout << ma << " " << mi << endl;

	cout << X - Y << endl;

	return 0;
}

0