結果
| 問題 | No.634 硬貨の枚数1 |
| コンテスト | |
| ユーザー |
@abcde
|
| 提出日時 | 2019-05-11 10:50:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 853 bytes |
| 記録 | |
| コンパイル時間 | 1,567 ms |
| コンパイル使用メモリ | 167,592 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-02 01:09:03 |
| 合計ジャッジ時間 | 3,459 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 66 |
ソースコード
// 上限設定誤り, 再提出.
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
// const LL LIMIT = 3250; // WAとなった
const LL LIMIT = 4500; // 上限を, 4500 * 4501 / 2 = 10127250 に 変更.
int main() {
// 1. 入力情報取得.
LL N;
cin >> N;
// 2. 硬貨準備.
LL coins[LIMIT];
for(int i = 0; i < LIMIT; i++) coins[i] = (i + 1) * (i + 2) / 2;
// for(int i = 0; i < LIMIT; i++) cout << coins[i] << endl;
// 3. 支払う硬貨をカウント.
LL ans = 0;
for(int i = LIMIT - 1; i >= 0; i--){
if(N == 0) break;
if(N >= coins[i]){
while(1){
if(N >= coins[i]) N -= coins[i], ans++;
else break;
}
}
}
// 4. 出力.
cout << ans << endl;
return 0;
}
@abcde