結果

問題 No.165 四角で囲え!
ユーザー tubo28tubo28
提出日時 2015-03-13 00:12:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 3,188 bytes
コンパイル時間 3,933 ms
コンパイル使用メモリ 158,484 KB
実行使用メモリ 5,256 KB
最終ジャッジ日時 2023-09-11 08:08:29
合計ジャッジ時間 4,242 ms
ジャッジサーバーID
(参考情報)
judge14 / 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,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 109 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 104 ms
4,376 KB
testcase_21 AC 105 ms
4,376 KB
testcase_22 AC 104 ms
4,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> istream & operator>>(istream & is, vector<T> &);
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _it(istream &, tuple<T...> &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _it(istream & is, tuple<T...> & t){ is >> get<n>(t); _it<n+1>(is, t); }
template<class...T> istream & operator>>(istream & is, tuple<T...> & t){ _it<0>(is, t); return is; }
template<class T, class U> istream & operator<<(istream & is, pair<T,U> & p){ return is >> p.first >> p.second; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> istream & operator>>(istream & is, vector<T> & v){ rep(i,v.size()) is >> v[i]; return is; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

typedef complex<int> P;

namespace std {
    bool operator<(P const & a, P const & b){
        return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
    }
}

int main(){
    int N,B;
    while(cin >> N >> B){
        vector<pair<P,int>> ps(N);
        rep(i,N){
            int x,y,p;
            cin >> x >> y >> p;
            ps[i] = mp(P(x,y),p);
        }
        sort(all(ps));
        ll ans = 0;
        rep(i,N){
            for(int j=i+1;j<=N;j++){
                vector<pair<double,int>> ys;
                loop(k,i,j){
                    ys.eb(ps[k].first.imag(),ps[k].second);
                }
                sort(all(ys), [](const pair<P,int> & a, const pair<P,int> & b){
                        int y1 = a.first.imag(), y2 = b.first.imag();
                        return y1 < y2;
                    });
                ll cur = 0;
                int ir = 0;
                rep(il,ys.size()){
                    while(ir < (int)ys.size() && cur+ys[ir].second <= B){
                        cur += ys[ir].second;
                        ir++;
                    }
                    ans = max(ans,ir-il);
                    cur-= ys[il].second;
                }
            }
        }
        cout << ans << endl;
    }
}
0