結果
問題 | No.1991 Secret Garden |
ユーザー |
![]() |
提出日時 | 2022-04-30 23:23:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 748 bytes |
コンパイル時間 | 1,570 ms |
コンパイル使用メモリ | 166,220 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 00:49:02 |
合計ジャッジ時間 | 2,141 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define ll long long#define rep(i,n) for(int i=0;i<n;i++)#define riano_ std::ios::sync_with_stdio(false);std::cin.tie(nullptr)int main() {riano_;ll N; cin >> N;//binary searchll l,r;l = 1; r = min(3*(ll)ceil(sqrt(N)),N);while(l<r){ll c = (l+r)/2;//unseen hightll t = N-c; bool ok = false;rep(i,c-1){ll p;if(i==0) p = 2*N-1;else p = 2*N-2*i;ll len = p-2*t-1;t -= len;if(t<=0){ok = true; break;}}if(!ok){l = c+1;}else r = c;}cout << N-l << endl;}