結果
| 問題 |
No.165 四角で囲え!
|
| コンテスト | |
| ユーザー |
tubo28
|
| 提出日時 | 2015-03-13 00:12:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,188 bytes |
| コンパイル時間 | 1,533 ms |
| コンパイル使用メモリ | 171,760 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 22:41:23 |
| 合計ジャッジ時間 | 4,268 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 6 WA * 13 |
ソースコード
#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;
}
}
tubo28