結果

問題 No.3815 Turn Signal (C++)
コンテスト
ユーザー tRue
提出日時 2026-11-23 14:32:24
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 50 ms / 2,000 ms
+ 193µs
コード長 366 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,357 ms
コンパイル使用メモリ 215,396 KB
実行使用メモリ 9,904 KB
スコア 269
最終ジャッジ日時 2026-11-23 14:32:30
合計ジャッジ時間 4,327 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(int step){
      | ^~~~
main.cpp:4:1: warning: 'int main(int)' takes only zero or two arguments [-Wmain]

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
int N,X,A[1<<20],i,start;
main(int step){
  for(cin>>N>>X;cin>>A[i];start=A[i++]<0?i:start);
  if(X<0){step*=-1;start--;X*=-1;}
  int ans = 0;
  int last_A = 0;
  for(;0<=start&&start<N&&last_A<X;start+=step) {
    int i=abs(A[start]);
    ans+=X<i?max(30-i+X,0):min(i-last_A,30);
    last_A=min(i,X);
  }
  cout<<ans;
}
0