結果
| 問題 |
No.549 素材合成システム
|
| ユーザー |
myanta
|
| 提出日時 | 2017-07-28 22:49:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 370 bytes |
| コンパイル時間 | 454 ms |
| コンパイル使用メモリ | 34,176 KB |
| 最終ジャッジ日時 | 2024-11-14 20:10:21 |
| 合計ジャッジ時間 | 1,811 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:42: error: ‘greater’ was not declared in this scope
21 | sort(x.begin(), x.end(), greater<int>());
| ^~~~~~~
main.cpp:21:50: error: expected primary-expression before ‘int’
21 | sort(x.begin(), x.end(), greater<int>());
| ^~~
main.cpp:19:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d", &x[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
using vi=vector<int>;
int main(void)
{
int n;
while(scanf("%d", &n)==1)
{
vi x(n);
for(int i=0;i<n;i++)
{
scanf("%d", &x[i]);
}
sort(x.begin(), x.end(), greater<int>());
int ans=x[0];
for(int i=1;i<n;i++)
{
ans+=x[i]/2;
}
printf("%d\n", ans);
}
return 0;
}
myanta