結果

問題 No.165 四角で囲え!
ユーザー 沙耶花沙耶花
提出日時 2021-11-03 12:24:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 5,000 ms
コード長 1,032 bytes
コンパイル時間 2,334 ms
コンパイル使用メモリ 206,564 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 03:15:53
合計ジャッジ時間 5,413 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 148 ms
5,376 KB
testcase_06 AC 31 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 73 ms
5,376 KB
testcase_12 AC 47 ms
5,376 KB
testcase_13 AC 36 ms
5,376 KB
testcase_14 AC 54 ms
5,376 KB
testcase_15 AC 57 ms
5,376 KB
testcase_16 AC 209 ms
5,376 KB
testcase_17 AC 197 ms
5,376 KB
testcase_18 AC 213 ms
5,376 KB
testcase_19 AC 218 ms
5,376 KB
testcase_20 AC 204 ms
5,376 KB
testcase_21 AC 198 ms
5,376 KB
testcase_22 AC 203 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 5000000000000000000



int main(){	
	
	int N,B;
	cin>>N>>B;
	
	vector<int> x(N),y(N),p(N);
	vector<int> t;
	vector<int> ind;
	rep(i,N){
		cin>>x[i]>>y[i]>>p[i];
		t.push_back(x[i]);
		ind.push_back(i);
	}
	sort(ind.begin(),ind.end(),[&](int a,int b){
		return y[a]<y[b];
	});
	
	
	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());
	int ans = 0;
	rep(i,t.size()){
		for(int j=i;j<t.size();j++){
			
			vector<pair<int,int>> temp;
			rep(k,N){
				if(x[ind[k]]>=t[i]&&x[ind[k]]<=t[j]){
					temp.emplace_back(y[ind[k]],p[ind[k]]);
				}
			}
			int s = 0,l = 0;
			rep(k,temp.size()){
				s += temp[k].second;
				if(k!=temp.size()-1 && temp[k+1].first==temp[k].first)continue;
				while(true){
					if(s<=B){
						if(l==0 || temp[l].first!=temp[l-1].first)break;
					}
					s -= temp[l].second;
					l++;
				}
				ans = max(ans,k-l+1);
			}
			
		}
	}
	cout<<ans<<endl;
	
	return 0;
	
}
0