結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
184
|
| 提出日時 | 2014-10-02 19:26:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,419 bytes |
| コンパイル時間 | 905 ms |
| コンパイル使用メモリ | 72,088 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-30 06:59:11 |
| 合計ジャッジ時間 | 1,740 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:49:29: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
49 | printf("%I64d\n",sc);return 0;
| ~~~~^ ~~
| | |
| int long long int
| %I64lld
main.cpp:52:29: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
52 | printf("%I64d\n",v*cst[0]+sc);return 0;
| ~~~~^ ~~~~~~~~~~~
| | |
| int long long int
| %I64lld
main.cpp:65:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
65 | printf("%I64d",minc+sc);
| ~~~~^ ~~~~~~~
| | |
| int long long int
| %I64lld
main.cpp:27:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | int n,v;scanf("%d%d",&n,&v);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:28:34: 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",&cst[i]),idx[i]=i;
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
using namespace std;
/*
正解してたら匿名でも問題投稿ができる(実現度さらにアップ)!!!
*/
int cst[101];
int idx[101];
struct smallercost{
bool operator()(const int &a, const int &b){
if(cst[a]!=cst[b])return cst[a]<cst[b];
return a<b;
}
};
int main(){
int n,v;scanf("%d%d",&n,&v);
for(int i=0;i<n;i++)scanf("%d",&cst[i]),idx[i]=i;
sort(idx,idx+n,smallercost());
long long sc=0;
for(int i=0;i<n;i++)sc+=cst[i];
vector<int> sm;
for(int i=1;i<n;i++)if(cst[0]>=cst[i])sm.push_back(i);
long long csts[101]={cst[0]};
int minidx=0;
for(int i=1;i<n;i++)csts[i]=cst[i]+csts[i-1];
double mincst=1000000001,dcsts[101];
for(int i=0;i<n;i++){
dcsts[i]=(double)csts[i]/(i+1);
if(mincst>dcsts[i])mincst=dcsts[i],minidx=i;
}
/*int uid=0;
while(uid+1<n&&cst[0]*(uid+1)>csts[uid+1])uid++;
*/
v-=n;
if(v<=0){
printf("%I64d\n",sc);return 0;
}
else if(idx[0]==0){
printf("%I64d\n",v*cst[0]+sc);return 0;
}
long long minc=v*csts[0],mcs;
long long ans;
for(int i=1;i<n;i++){
if(dcsts[i]<dcsts[0]){
mcs=v/(i+1)*csts[i];
if(v%(i+1))mcs+=csts[v%(i+1)-1];
if(minc>mcs)minc=mcs;
//printf("%d\n",(int)mcs);
}
}
printf("%I64d",minc+sc);
return 0;
}
184