結果

問題 No.1687 What the Heck?
ユーザー umezoumezo
提出日時 2021-09-24 22:47:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 1,915 ms
コンパイル使用メモリ 200,568 KB
実行使用メモリ 6,264 KB
最終ジャッジ日時 2023-09-18 21:53:40
合計ジャッジ時間 3,103 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 9 ms
4,384 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 23 ms
6,264 KB
testcase_13 AC 23 ms
6,168 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:22:23: 警告: ‘num’ may be used uninitialized [-Wmaybe-uninitialized]
   22 |   else cout<<max(S[num],S[n]-2*num)<<endl;
      |                       ^
main.cpp:17:6: 備考: ‘num’ はここで定義されています
   17 |   ll num;
      |      ^~~

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n;
  cin>>n;
  vector<ll> P(n),S(n+1);
  rep(i,n) cin>>P[i];
  rep(i,n) S[i+1]=S[i]+P[i];
  ll num;
  rep(i,n){
    if(P[i]==n) num=i+1;
  }
  if(n==1) cout<<0<<endl;
  else cout<<max(S[num],S[n]-2*num)<<endl;
      
  return 0;
}
0