結果

問題 No.1519 Diversity
ユーザー umezoumezo
提出日時 2021-05-28 22:34:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 688 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 198,416 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 00:34:26
合計ジャッジ時間 5,079 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

vector<int> G[500];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  int k=0;
  for(int i=1;i<=500;i++){
    if(2*n-2-i*(i+1)/2>=n-i) k=i;
  }
  G[0].push_back(1);
  rep(i,k) G[1].push_back(2+i);
  int now=k+2;
  int h=1,b=max(1,k-2);
  while(now<=n){
    h++;
    rep(i,b){
      G[h].push_back(now);
      now++;
    }
    b=max(1,b-1);
  }
  cout<<k<<endl;
  for(int i=0;i<h;i++){
    for(int j=0;j<(int)G[i+1].size();j++){
      cout<<G[i][0]<<" "<<G[i+1][j]<<endl;
    }
  }

  return 0;
}
0