結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー FF256grhyFF256grhy
提出日時 2020-08-07 23:18:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,621 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 205,812 KB
実行使用メモリ 5,512 KB
最終ジャッジ日時 2023-10-25 04:41:31
合計ジャッジ時間 6,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n, s, t);
	s--; t--;
	vector<LL> a(n);
	cin >> a;
	
	LL ans = 0;
	array<vector<LL>, 2> v;
	{
		int c = 0;
		inc(ii, n) {
			int i = (s + ii) % n;
			if(i == s) { ans += a[i]; }
			ef(i == t) { ans -= a[i]; c++; }
			else { v[c].PB(a[i]); }
		}
		assert(c == 1);
	}
	
	if(n % 2 == 1) {
		UR;/////
		if(SI(v[0]) % 2 == 1) {
			ans += v[0].FR;
			reverse(ALL(v[0]));
			v[0].pop_back();
			reverse(ALL(v[0]));
		} else {
			ans += v[1].BA;
			v[1].pop_back();
		}
	}
	
	int x = SI(v[0]);
	int y = SI(v[1]);
	assert(x % 2 == y % 2);
	if(x % 2 == 1) {
		ans += abs(v[0][x / 2] - v[1][y / 2]);
	}
	inc(i, x / 2) { ans += v[0][i] - v[0][x - 1 - i]; }
	inc(i, y / 2) { ans += v[1][i] - v[1][y - 1 - i]; }
	OUT(ans);
}
0