結果
問題 |
No.31 悪のミックスジュース
|
ユーザー |
![]() |
提出日時 | 2017-05-04 09:30:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 626 bytes |
コンパイル時間 | 409 ms |
コンパイル使用メモリ | 37,888 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-14 06:44:30 |
合計ジャッジ時間 | 1,212 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:22:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d", &c[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio> #include<vector> using namespace std; using ll=long long; int main(void) { int n, v, i, ln, m; vector<int> c; ll s, l; double ave, ave_min; while(scanf("%d%d", &n, &v)==2) { c.resize(n); s=0; for(i=0;i<n;i++) { scanf("%d", &c[i]); s+=c[i]; } if(v<=n) { printf("%lld\n", s); continue; } ln=n; ave_min=(double)s/ln; v-=n; l=0; for(i=0;i<n;i++) { l+=c[i]; ave=(double)l/(i+1); if(ave_min>ave) { ave_min=ave; ln=i+1; } } m=v-v/ln*ln; for(i=0;i<ln;i++) { s+=(ll)c[i]*(v/ln+(i<m)); } printf("%lld\n", s); } return 0; }