結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2019-03-06 15:35:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 590 bytes |
| コンパイル時間 | 1,530 ms |
| コンパイル使用メモリ | 168,372 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 14:35:19 |
| 合計ジャッジ時間 | 2,572 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 WA * 29 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n, s) for(int (i) = 0; (i) < (n); (i) += (s))
using namespace std;
int main()
{
int num, result = 0;
cin >> num;
vector<int> v(num + 5, 0);
for (int i = 0; i < num; i++)
{
int tmp;
cin >> tmp;
v[i] = tmp;
}
for (int i = 0; i < num; i++)
{
vector<int>::iterator maxIt = max_element(v.begin(), v.end());
size_t maxIndex = distance(v.begin(), maxIt);
result += v[maxIndex];
if (maxIndex > 0)
v[maxIndex - 1] = 0;
v[maxIndex] = 0;
v[maxIndex + 1] = 0;
}
cout << result << endl;
}