結果

問題 No.761 平均値ゲーム
ユーザー bal4u
提出日時 2019-09-05 08:07:32
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,015 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 30,336 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-31 19:01:56
合計ジャッジ時間 5,314 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'in':
main.c:10:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
   10 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:16:27: note: in expansion of macro 'gc'
   16 |         ll n = 0; int c = gc();
      |                           ^~

ソースコード

diff #
プレゼンテーションモードにする

// yukicoder: 761
// 2019.6.15 bal4u
#include <stdio.h>
typedef long long ll;
////
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
ll in() { //
ll n = 0; int c = gc();
do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
return n;
}
int N;
ll a[100005];
ll s[100005];
// a[i]>key i
int upper_bound(int l, int r, ll x) {
int m;
while (l+1 < r) {
m = (l+r) >> 1;
if (a[m] <= x) l = m; else r = m;
}
return a[l] <= x? r: l;
}
int dfs(int l, int r, int first) {
int m; ll x;
if (l > r) return !first;
if (a[l] == a[r]) return first;
x = (s[r]-s[l-1]) / (r-l+1);
if ((s[r]-s[l-1]) % (r-l+1) == 0) x--;
m = upper_bound(l, r+1, x);
return (dfs(l, m-1, !first) == first ||
dfs(m, r, !first) == first)? first: !first;
}
int main()
{
int i;
N = (int)in(); for (i = 1; i <= N; i++) a[i] = in(), s[i] = s[i-1] + a[i];
puts(dfs(1, N, 1)? "First": "Second");
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0