結果
| 問題 | No.165 四角で囲え! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-10 05:03:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 475 ms / 5,000 ms |
| コード長 | 998 bytes |
| コンパイル時間 | 816 ms |
| コンパイル使用メモリ | 83,932 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 06:11:41 |
| 合計ジャッジ時間 | 6,414 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main()
| ^~~~
ソースコード
#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;
}