結果
| 問題 |
No.165 四角で囲え!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-28 10:43:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,531 bytes |
| コンパイル時間 | 1,096 ms |
| コンパイル使用メモリ | 92,180 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-01 15:23:47 |
| 合計ジャッジ時間 | 22,894 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 WA * 3 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
#define inRange(x,a,b) (a <= x && x <= b)
typedef pair<int,int> pii;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n, b;
cin >> n >> b;
vector<pair<pii,int>> vp;
for(int i = 0; i < n; i++){
int x, y, p;
cin >> x >> y >> p;
vp.push_back({{x,y},p});
}
sort(vp.begin(), vp.end());
int ans = 0;
for(int i = 0; i < n; i++){
for(int j = i; j < n; j++){
int low = vp[i].first.second, high = vp[j].first.second;
if(low > high) swap(low, high);
map<int,int> ms, mv;
for(int k = 0; k < n; k++){
if(inRange(vp[k].first.second, low, high)){
ms[vp[k].first.first] += (vp[k].second);
mv[vp[k].first.first]++;
}
}
vector<int> vs, vv;
for(auto p : ms) vs.push_back(p.second);
for(auto p : mv) vv.push_back(p.second);
int l = 0, r = 0, sum = 0, cnt = 0;
while(l < vs.size()){
while(r < vs.size() && sum+vs[r] <= b){
sum += vs[r];
cnt += vv[r];
r++;
}
ans = max(ans, cnt);
sum -= vs[l];
cnt -= vv[l];
l++;
if(vs[r] > b) l = ++r;
}
}
}
cout << ans << endl;
return 0;
}