結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2017-08-24 22:13:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,196 bytes |
| コンパイル時間 | 804 ms |
| コンパイル使用メモリ | 61,704 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 16:52:23 |
| 合計ジャッジ時間 | 2,166 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <stack>
#include <utility>
#include <queue>
//#include <random>
#include <time.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define SWAP(a,b) (a ^= b,b = a ^ b,a ^= b)
#define swap(type,a,b) do{type _c;_c=a;a=b;b=_c;}while(0)
using namespace std;
typedef long long int lint;
template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
if (v.empty()) {
cout << "{ }";
return ostr;
}
cout << "{" << v.front();
for (auto itr = ++v.begin(); itr != v.end(); itr++) {
cout << ", " << *itr;
}
cout << "}";
return ostr;
}
int yuki0045()
{
int n, tmp;
cin >> n;
int* v = new int[n + 3];
v[0] = v[1] = v[2] = 0;
for (int i = 0; i < n; i++) {
cin >> tmp;
v[i + 3] = max(v[i], v[i + 1]) + tmp;
}
cout << max(v[n + 1], v[n + 2]) << endl;
delete[] v;
return 0;
}
int main()
{
//clock_t start, end;
//start = clock();
yuki0045();
//end = clock();
//printf("%d msec.\n", end - start);
return 0;
}