結果

問題 No.1687 What the Heck?
ユーザー umezo
提出日時 2021-09-24 22:47:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 193,860 KB
最終ジャッジ日時 2025-01-24 17:37:38
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:23: warning: ‘num’ may be used uninitialized [-Wmaybe-uninitialized]
   22 |   else cout<<max(S[num],S[n]-2*num)<<endl;
      |                       ^
main.cpp:17:6: note: ‘num’ was declared here
   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