結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー akun0716akun0716
提出日時 2020-09-22 19:38:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,777 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 82,820 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-08 16:56:28
合計ジャッジ時間 3,218 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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 (mi != INF) {
		//if (Y > X)swap(X, Y);
		X += ma;
		Y += mi;
	}
	else {
		X += ma;
	}
	//cout << ma << " " << mi << endl;

	cout << X - Y << endl;

	return 0;
}

0