結果
| 問題 |
No.1150 シュークリームゲーム(Easy)
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2020-08-09 01:48:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,654 bytes |
| コンパイル時間 | 1,005 ms |
| コンパイル使用メモリ | 94,952 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-02 13:07:12 |
| 合計ジャッジ時間 | 3,167 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 WA * 3 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1150.cc: No.1150 シュークリームゲーム(Easy) - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 100000;
const int MAX_N2 = MAX_N * 2;
const long long LINF = 1LL << 62;
/* typedef */
typedef long long ll;
/* global variables */
int as[MAX_N2];
ll ass[MAX_N2 + 1];
/* subroutines */
/* main */
int main() {
int n, s, t;
scanf("%d%d%d", &n, &s, &t);
s--, t--;
int n2 = n * 2;
for (int i = 0; i < n; i++) scanf("%d", as + i), as[i + n] = as[i];
for (int i = 0; i < n2; i++) ass[i + 1] = ass[i] + as[i];
int s0, t0, t1, s1;
if (s < t)
s0 = s, t0 = t1 = t, s1 = s + n;
else
s0 = s, t0 = t + n, t1 = t, s1 = s;
int k = t0 - (s0 + 1), l = s1 - (t1 + 1);
int hk = k / 2, hl = l / 2;
int w0 = t0 - hk, w1 = t1 + 1 + hl;
ll x = as[s], y = as[t];
if (! (k & 1) || ! (l & 1)) {
x += (ass[w0] - ass[s0 + 1]) + (ass[s1] - ass[w1]);
y += (ass[t0] - ass[w0]) + (ass[w1] - ass[t1 + 1]);
}
else {
if (as[w0] > as[w1]) {
x += (ass[w0] - ass[s0 + 1]) + (ass[s1] - ass[w1 + 1]);
y += (ass[t0] - ass[w0]) + (ass[w1 + 1] - ass[t1 + 1]);
}
else {
x += (ass[w0 - 1] - ass[s0 + 1]) + (ass[s1] - ass[w1]);
y += (ass[t0] - ass[w0 - 1]) + (ass[w1] - ass[t1 + 1]);
}
}
printf("%lld\n", x - y);
return 0;
}
tnakao0123