結果
問題 |
No.3165 [Cherry 7th Tune A] Croissants Continu
|
ユーザー |
![]() |
提出日時 | 2025-05-31 16:56:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 655 bytes |
コンパイル時間 | 602 ms |
コンパイル使用メモリ | 41,344 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-31 16:56:27 |
合計ジャッジ時間 | 3,079 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%d", &tn); | ~~~~~^~~~~~~~~~~ main.cpp:33:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:34:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | for (int i = 0; i < n; i++) scanf("%d", as + i); | ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3165.cc: No.3165 [Cherry 7th Tune A] Croissants Continu - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 300000; /* typedef */ using ll = long long; /* global variables */ int as[MAX_N]; /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); ll s = 0; for (int i = 0; i < n; i++) s += as[i]; int maxa = *max_element(as, as + n); if (maxa * 2 > s) s = (s - maxa) * 2 + 1; printf("%lld\n", s); } return 0; }