結果
| 問題 | No.1687 What the Heck? |
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2021-09-24 22:40:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 402 bytes |
| 記録 | |
| コンパイル時間 | 2,317 ms |
| コンパイル使用メモリ | 193,464 KB |
| 最終ジャッジ日時 | 2025-01-24 17:35:26 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:28: warning: ‘num’ may be used uninitialized [-Wmaybe-uninitialized]
20 | cout<<max(0LL,n*(n+1)/2-2*num)<<endl;
| ~^~~~
main.cpp:16:6: note: ‘num’ was declared here
16 | ll num;
| ^~~
ソースコード
#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);
rep(i,n) cin>>P[i];
ll num;
rep(i,n){
if(P[i]==n) num=i+1;
}
cout<<max(0LL,n*(n+1)/2-2*num)<<endl;
return 0;
}
umezo