結果

問題 No.1583 Building Blocks
ユーザー tnakao0123
提出日時 2021-07-04 02:30:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 951 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 99,140 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 18:00:39
合計ジャッジ時間 2,266 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1583.cc:  No.1583 Building Blocks - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

typedef long long ll;
typedef pair<int,int> pii;

/* global variables */

pii ps[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int w, s;
    scanf("%d%d", &w, &s);
    ps[i] = pii(w + s, s);
  }
  sort(ps, ps + n);

  int c = 0;
  ll wsum = 0;
  for (int i = 0; i < n; i++) {
    int w = ps[i].first - ps[i].second, s = ps[i].second;
    if (wsum <= s) c++, wsum += w;
  }

  printf("%d\n", c);
  return 0;
}
0