結果

問題 No.165 四角で囲え!
ユーザー kotatsugamekotatsugame
提出日時 2020-02-10 05:03:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 541 ms / 5,000 ms
コード長 998 bytes
コンパイル時間 1,089 ms
コンパイル使用メモリ 83,980 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 12:43:54
合計ジャッジ時間 7,479 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 269 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 350 ms
6,676 KB
testcase_06 AC 66 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 224 ms
6,676 KB
testcase_12 AC 134 ms
6,676 KB
testcase_13 AC 77 ms
6,676 KB
testcase_14 AC 130 ms
6,676 KB
testcase_15 AC 129 ms
6,676 KB
testcase_16 AC 522 ms
6,676 KB
testcase_17 AC 507 ms
6,676 KB
testcase_18 AC 541 ms
6,676 KB
testcase_19 AC 527 ms
6,676 KB
testcase_20 AC 513 ms
6,676 KB
testcase_21 AC 516 ms
6,676 KB
testcase_22 AC 511 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,B;
vector<pair<pair<int,int>,int> >XY;
main()
{
	cin>>N>>B;
	for(int i=0;i<N;i++)
	{
		int x,y,p;cin>>x>>y>>p;
		XY.push_back(make_pair(make_pair(x,y),p));
	}
	sort(XY.begin(),XY.end());
	int ans=0;
	for(int i=0;i<N;i++)
	{
		if(i!=0&&XY[i-1].first.first==XY[i].first.first)continue;
		for(int j=i;j<N;j++)
		{
			if(j+1<N&&XY[j].first.first==XY[j+1].first.first)continue;
			vector<pair<int,int> >y;
			for(int k=i;k<=j;k++)y.push_back(make_pair(XY[k].first.second,XY[k].second));
			sort(y.begin(),y.end());
			int l=0,nowb=0;
			for(int r=0;r<y.size();)
			{
				while(r+1<y.size()&&y[r].first==y[r+1].first)
				{
					nowb+=y[r].second;
					r++;
				}
				nowb+=y[r].second;
				r++;
				while(l<=r&&nowb>B)
				{
					while(l+1<y.size()&&y[l].first==y[l+1].first)
					{
						nowb-=y[l].second;
						l++;
					}
					nowb-=y[l].second;
					l++;
				}
				ans=max(ans,r-l);
			}
		}
	}
	cout<<ans<<endl;
}
0