提出 #74853487


ソースコード 拡げる

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
int main() {
  int N;
  cin >> N;
  vector<ll> L(N);
  REP(i,N)cin >> L[i];


  int ans = 0;

  for (int bit = 0;bit < (1 << N);bit++) {
    vector<bool> is_r(N);
    for (int j = 0;j < N;j++) {
      if ((bit >> j) & 1)is_r[j] = true;
      else is_r[j] = false;
    }

    int cur_ans = 0;
    ll now = 1;
    REP(i,N) {
      ll before = now;
      ll sign = is_r[i] ? 1 : -1;
      ll next = now + 2 * L[i] * sign;

      if (before > 0 & next < 0 || before < 0 && next > 0)cur_ans++;
      now = next;
    }

    if (ans < cur_ans)ans = cur_ans;
  }

  cout << ans << endl;
}

提出情報

提出日時
問題 C - Sneaking Glances
ユーザ knr_imtr
言語 C++23 (GCC 15.2.0)
得点 300
コード長 903 Byte
結果 AC
実行時間 103 ms
メモリ 3600 KiB

コンパイルエラー

./Main.cpp: In function 'int main()':
./Main.cpp:31:18: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   31 |       if (before > 0 & next < 0 || before < 0 && next > 0)cur_ans++;
      |           ~~~~~~~^~~
./Main.cpp:31:47: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   31 |       if (before > 0 & next < 0 || before < 0 && next > 0)cur_ans++;
      |                                    ~~~~~~~~~~~^~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 34
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt
ケース名 結果 実行時間 メモリ
sample_01.txt AC 1 ms 3500 KiB
sample_02.txt AC 1 ms 3556 KiB
sample_03.txt AC 98 ms 3560 KiB
test_01.txt AC 1 ms 3560 KiB
test_02.txt AC 1 ms 3468 KiB
test_03.txt AC 1 ms 3552 KiB
test_04.txt AC 1 ms 3468 KiB
test_05.txt AC 103 ms 3416 KiB
test_06.txt AC 51 ms 3560 KiB
test_07.txt AC 99 ms 3584 KiB
test_08.txt AC 1 ms 3408 KiB
test_09.txt AC 93 ms 3560 KiB
test_10.txt AC 1 ms 3560 KiB
test_11.txt AC 98 ms 3600 KiB
test_12.txt AC 101 ms 3468 KiB
test_13.txt AC 1 ms 3584 KiB
test_14.txt AC 1 ms 3560 KiB
test_15.txt AC 99 ms 3408 KiB
test_16.txt AC 47 ms 3404 KiB
test_17.txt AC 100 ms 3500 KiB
test_18.txt AC 95 ms 3560 KiB
test_19.txt AC 1 ms 3560 KiB
test_20.txt AC 1 ms 3456 KiB
test_21.txt AC 1 ms 3408 KiB
test_22.txt AC 1 ms 3404 KiB
test_23.txt AC 1 ms 3500 KiB
test_24.txt AC 1 ms 3560 KiB
test_25.txt AC 1 ms 3372 KiB
test_26.txt AC 1 ms 3472 KiB
test_27.txt AC 99 ms 3472 KiB
test_28.txt AC 98 ms 3416 KiB
test_29.txt AC 83 ms 3412 KiB
test_30.txt AC 83 ms 3416 KiB
test_31.txt AC 83 ms 3560 KiB