結果

問題 No.165 四角で囲え!
ユーザー motimoti
提出日時 2015-04-12 18:52:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 1,248 ms
コンパイル使用メモリ 149,968 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 19:45:40
合計ジャッジ時間 3,468 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 10 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 129 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 31 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 69 ms
4,380 KB
testcase_21 AC 69 ms
4,376 KB
testcase_22 AC 69 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

#define chmax(a,x) a = max(a, x)

typedef long long ll;

ll N, B;
typedef pair<double, double> pdd;
typedef pair<pdd, double> pd3;
pd3 p[444];

int main() {

  cin >> N >> B;
  rep(i, N) {
    double x, y, sc; cin >> x >> y >> sc;
    p[i] = {{x, y}, sc};
  }

  sort(p, p+N);

  ll ans = 0;

  rep(i, N) REP(j, i+1, N) {
    int L = i, R = i;
    ll sum = 0;
    while(L <= j && R <= j) {
      if(sum + p[R].second <= B) {
        sum += p[R++].second;
        chmax(ans, (ll)(R-L));
      }
      else {
        sum -= p[L++].second;
        if(sum < 0) { R = L; sum = 0; }
      }
    }
  }

  cout << ans << endl;

  return 0;
}
0