結果

問題 No.1570 Blocks
ユーザー umezoumezo
提出日時 2021-06-27 13:55:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,023 bytes
コンパイル時間 2,150 ms
コンパイル使用メモリ 209,740 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2023-09-07 17:42:56
合計ジャッジ時間 5,240 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 WA -
testcase_02 AC 26 ms
6,344 KB
testcase_03 AC 28 ms
6,368 KB
testcase_04 AC 23 ms
5,020 KB
testcase_05 AC 24 ms
5,112 KB
testcase_06 AC 22 ms
5,092 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 28 ms
6,548 KB
testcase_09 AC 32 ms
6,728 KB
testcase_10 AC 29 ms
6,332 KB
testcase_11 AC 32 ms
6,520 KB
testcase_12 AC 33 ms
6,620 KB
testcase_13 AC 36 ms
6,704 KB
testcase_14 AC 37 ms
6,752 KB
testcase_15 AC 17 ms
4,876 KB
testcase_16 AC 37 ms
6,616 KB
testcase_17 AC 14 ms
4,696 KB
testcase_18 AC 30 ms
6,444 KB
testcase_19 AC 15 ms
4,816 KB
testcase_20 AC 17 ms
4,700 KB
testcase_21 AC 26 ms
6,340 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 33 ms
6,588 KB
testcase_33 AC 33 ms
6,628 KB
testcase_34 AC 35 ms
6,636 KB
testcase_35 AC 33 ms
6,592 KB
testcase_36 AC 35 ms
6,632 KB
testcase_37 AC 32 ms
6,616 KB
testcase_38 WA -
testcase_39 AC 37 ms
6,612 KB
testcase_40 AC 35 ms
6,572 KB
testcase_41 AC 33 ms
6,732 KB
testcase_42 AC 38 ms
6,708 KB
testcase_43 AC 38 ms
6,804 KB
testcase_44 AC 38 ms
6,696 KB
testcase_45 AC 37 ms
6,788 KB
testcase_46 AC 34 ms
6,948 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:41:7: 警告: ‘anum’ may be used uninitialized [-Wmaybe-uninitialized]
   41 |   int anum;
      |       ^~~~

ソースコード

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;

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  vector<ll> A(n),B(n);
  rep(i,n) cin>>A[i]>>B[i];
  
  vector<pair<ll,ll>> C;
  rep(i,n) C.push_back({B[i],A[i]});
  C.push_back({0,0});
  sort(ALL(C));
  
  
  
  bool b=true;
  ll sum=0;
  int num;
  for(int i=0;i<=n;i++){
    if(sum>C[i].first){
      b=false;
      num=i;
      break;
    }
    sum+=C[i].second;
  }
  if(b){
    cout<<"Yes"<<endl;
    return 0;
  }
  
  ll t=0;
  int anum;
  for(int i=0;i<num;i++){
    if(t>C[num].first){
      anum=i;
      break;
    }
    t+=C[i].second;
  }
  
  auto p=C[num];
  C.erase(C.begin()+num);
  C.insert(C.begin()+anum+1,p);
  
  
  b=true;
  sum=0;
  for(int i=0;i<=n;i++){
    if(sum>C[i].second){
      b=false;
      break;
    }
    sum+=C[i].second;
  }
  if(b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}
0