結果
| 問題 | No.999 てん vs. ほむ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-09 13:08:23 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 470 bytes |
| 記録 | |
| コンパイル時間 | 1,121 ms |
| コンパイル使用メモリ | 181,720 KB |
| 実行使用メモリ | 7,976 KB |
| 最終ジャッジ日時 | 2026-05-08 04:30:55 |
| 合計ジャッジ時間 | 3,161 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 20 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:26:13: warning: 'score' may be used uninitialized [-Wmaybe-uninitialized]
26 | score += l;
| ~~~~~~^~~~
main.cpp:16:8: note: 'score' was declared here
16 | long score;
| ^~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
long n;
cin >> n;
vector<long> v(2*n);
for(int i = 0; i < 2*n; i++){
cin >> v.at(i);
}
int left = 0;
int right = 2 * n -1;
long score;
for(int i = 0; i < n; i++){
long l = v.at(left) - v.at(left + 1);
long r = v.at(right) - v.at(right -1);
if(r >= l){
score += r;
right -= 2;
} else {
score += l;
left += 2;
}
}
cout << score << endl;
}