結果
問題 | No.165 四角で囲え! |
ユーザー |
|
提出日時 | 2015-04-05 14:51:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 608 ms / 5,000 ms |
コード長 | 1,504 bytes |
コンパイル時間 | 1,081 ms |
コンパイル使用メモリ | 95,336 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 03:27:37 |
合計ジャッジ時間 | 8,393 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> using namespace std; class Data { public: int x, y, p; bool operator<(const Data& d) const{ return x < d.x; } }; int main() { int n, b; cin >> n >> b; vector<Data> d(n); for(int i=0; i<n; ++i) cin >> d[i].x >> d[i].y >> d[i].p; sort(d.begin(), d.end()); int ans = 0; for(int s=0; s<n; ++s){ for(int t=0; t<n; ++t){ int i = 0; int j = 0; int cnt = 0; int sum = 0; while(j < n){ do{ if(d[s].y <= d[j].y && d[j].y <= d[t].y){ ++ cnt; sum += d[j].p; } ++ j; }while(j < n && d[j].x == d[j-1].x); while(b < sum || (0 < i && i < n && d[i].x == d[i-1].x)){ if(d[s].y <= d[i].y && d[i].y <= d[t].y){ -- cnt; sum -= d[i].p; } ++ i; } ans = max(ans, cnt); } } } cout << ans << endl; return 0; }