結果
| 問題 |
No.3066 Collecting Coins Speedrun 1
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-03-22 18:22:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 2,000 ms |
| コード長 | 488 bytes |
| コンパイル時間 | 540 ms |
| コンパイル使用メモリ | 40,064 KB |
| 実行使用メモリ | 7,324 KB |
| 最終ジャッジ日時 | 2025-03-22 18:22:46 |
| 合計ジャッジ時間 | 2,143 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:28:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | for (int i = 0; i < n; i++) scanf("%d", cs + i);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 3066.cc: No.3066 Collecting Coins Speedrun 1 - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 100000;
/* typedef */
/* global variables */
int cs[MAX_N];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", cs + i);
int c0 = min(cs[0], 0), c1 = max(cs[n - 1], 0);
int l = (c1 - c0) * 2;
printf("%d\n", l);
return 0;
}
tnakao0123