結果
| 問題 | No.634 硬貨の枚数1 |
| コンテスト | |
| ユーザー |
masakt
|
| 提出日時 | 2018-01-19 22:10:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,545 bytes |
| コンパイル時間 | 1,661 ms |
| コンパイル使用メモリ | 125,512 KB |
| 実行使用メモリ | 1,635,524 KB |
| 最終ジャッジ日時 | 2024-12-25 19:04:01 |
| 合計ジャッジ時間 | 161,169 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 3 |
| other | TLE * 1 MLE * 74 |
ソースコード
#include <algorithm>
#include <bitset>
#include <chrono>
#include <complex>
#include <cstdint>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define all(r) r.begin(),r.end()
using namespace std;
constexpr int32_t INF = 0x3F3F3F3F;
using ll = int64_t;
using vll = vector<ll>;
struct Solution {
void solve(std::istream& in, std::ostream& out) {
ll n;
in >> n;
vll table;
for (int k = 0; k < INF; k++) {
ll t = k * (k + 1) / 2;
if (t < 0) {
break;
}
table.emplace_back(t);
}
ll len = table.size();
vll dp(n + 1);
fill(all(dp), -1);
dp[0] = 0;
for (int i = 0; i < len; i++) {
for (int j = table[i]; j <= n; j++) {
if (dp[j] >= 0) {
dp[j] = table[i];
}
else {
dp[j] = dp[j - table[i]] - 1;
}
}
}
out << -dp[n] << '\n';
}
};
void solve(std::istream& in, std::ostream& out) {
out << std::setprecision(12);
Solution solution;
solution.solve(in, out);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
istream& in = cin;
ostream& out = cout;
solve(in, out);
return 0;
}
masakt