結果

問題 No.165 四角で囲え!
ユーザー koba-e964koba-e964
提出日時 2015-06-11 19:16:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,531 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 79,392 KB
実行使用メモリ 4,960 KB
最終ジャッジ日時 2023-09-20 20:55:55
合計ジャッジ時間 2,801 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
4,608 KB
testcase_02 AC 3 ms
4,604 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,804 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 3 ms
4,576 KB
testcase_09 AC 3 ms
4,604 KB
testcase_10 AC 3 ms
4,724 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;
const int N = 400;
int x[N], y[N], p[N];
int dp[N][N], dp2[N][N];

int main(void){
  int n, b;
  cin >> n >> b;
  REP(i, 0, n) {
    cin >> x[i] >> y[i] >> p[i];
  }
  set<int> ixp;
  REP(i, 0, n) {
    ixp.insert(x[i]);
  }
  set<int> iyp;
  REP(i, 0, n) {
    iyp.insert(y[i]);
  }
  vector<int> ixv(ixp.begin(), ixp.end());
  vector<int> iyv(iyp.begin(), iyp.end());
  REP(i, 0, n) {
    int pp = lower_bound(ixv.begin(), ixv.end(), x[i]) - ixv.begin();
    int qq = lower_bound(iyv.begin(), iyv.end(), y[i]) - iyv.begin();
    dp[pp + 1][qq + 1] += p[i];
    dp2[pp + 1][qq + 1] ++;
  }
  REP(i, 1, N) {
    REP(j, 0, N) {
      dp[i][j] += dp[i - 1][j];
      dp2[i][j] += dp2[i - 1][j];
    }
  }
  int qx = ixv.size() + 1;
  int qy = iyv.size() + 1;
  int ma = 0;
  REP(i, 0, qx) {
    REP(j, i + 1, qx) {
      int mi = 0;
      int tot = 0;
      int tot2 = 0;
      int l = 0;
      REP(k, 0, qy) {
	while (l < qy && tot <= b) {
	  ma = max(ma, tot2);
	  l++;
	  tot += dp[j][l] - dp[i][l];
	  tot2 += dp2[j][l] - dp2[i][l];
	}
	tot -= dp[j][k] - dp[i][k];
	tot2 -= dp2[j][k] - dp[i][k];
      }
    }
  }
  cout << ma << endl;
}
0