結果

問題 No.165 四角で囲え!
ユーザー fiordfiord
提出日時 2015-08-26 08:44:21
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,009 bytes
コンパイル時間 3,478 ms
コンパイル使用メモリ 158,296 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 18:31:01
合計ジャッジ時間 34,987 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,423 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2,130 ms
4,376 KB
testcase_06 AC 408 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 786 ms
4,384 KB
testcase_12 AC 317 ms
4,380 KB
testcase_13 AC 385 ms
4,376 KB
testcase_14 AC 423 ms
4,376 KB
testcase_15 AC 390 ms
4,380 KB
testcase_16 AC 3,284 ms
4,376 KB
testcase_17 AC 2,795 ms
4,376 KB
testcase_18 TLE -
testcase_19 AC 3,054 ms
4,380 KB
testcase_20 AC 2,797 ms
4,376 KB
testcase_21 AC 2,762 ms
4,380 KB
testcase_22 AC 2,794 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
map<int,int> mx,my;
vector<pair<int,int>> ls[402];
int main(){
	int n,b;	cin>>n>>b;
	int x[n],y[n],p[n];
	for(int i=0;i<n;i++)	cin>>x[i]>>y[i]>>p[i],mx[x[i]]=my[y[i]]=0;
	mx[(1<<30)]=mx[-(1<<30)]=my[(1<<30)]=my[-(1<<30)]=0;
	int cnt=0;
	for(auto it=mx.begin();it!=mx.end();it++)	it->second=cnt++;
	cnt=0;
	for(auto it=my.begin();it!=my.end();it++)	it->second=cnt++;
	for(int i=0;i<n;i++)	ls[my[y[i]]].push_back(make_pair(x[i],p[i]));
	int ans=0;
	for(int x1=0;x1<(int)mx.size();x1++){
		for(int x2=x1;x2<(int)mx.size();x2++){
			int y1=0,point=0,tmp=0;
			for(int y2=0;y2<(int)my.size();y2++){
				for(auto it=ls[y2].begin();it!=ls[y2].end();it++){
					if(x1<=mx[it->first]&&mx[it->first]<=x2)	point+=it->second,tmp++;
				}
				while(point>b){
					for(auto it=ls[y1].begin();it!=ls[y1].end();it++){
						if(x1<=mx[it->first]&&mx[it->first]<=x2)	point-=it->second,tmp--;
					}
					y1++;
				}
				ans=max(ans,tmp);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
0