結果

問題 No.165 四角で囲え!
ユーザー h_nosonh_noson
提出日時 2016-05-02 01:11:32
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,457 bytes
コンパイル時間 792 ms
コンパイル使用メモリ 73,908 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-04-15 09:01:16
合計ジャッジ時間 17,938 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,(int)(n)-1,0)
#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP(i,0,(int)(n)-1)
#define INF 100000000

typedef long long ll;

int main() {
    int i, j, k, l, n, b;
    int x[400], y[400], p[400];
    int points[401][401] {};
    int cnt[401][401] {};
    map<int,int> mpx, mpy;
    cin >> n >> b;
    rep (i,n) {
        cin >> x[i] >> y[i] >> p[i];
        mpx[x[i]]++;
        mpy[y[i]]++;
    }
    j = 1;
    for (auto& e : mpx) e.second = j++;
    j = 1;
    for (auto& e : mpy) e.second = j++;
    rep (i,n) {
        x[i] = mpx[x[i]];
        y[i] = mpy[y[i]];
        points[x[i]][y[i]] = p[i];
        cnt[x[i]][y[i]] = 1;
    }
    rep (i,mpx.size()+1) REP (j,1,mpy.size()+1) {
        points[i][j] += points[i][j-1];
        cnt[i][j] += cnt[i][j-1];
    }
    rep (j,mpy.size()+1) REP (i,1,mpx.size()+1) {
        points[i][j] += points[i-1][j];
        cnt[i][j] += cnt[i-1][j];
    }
    int ans = 0;
    REP (i,1,mpx.size()+1) REP (j,i,mpx.size()+1) REP (k,1,mpy.size()+1) REP (l,k,mpy.size()+1) {
        int pnt = points[j][l] - points[j][k-1] - points[i-1][k] + points[i-1][k-1];
        int num = cnt[j][l] - cnt[j][k-1] - cnt[i-1][k] + cnt[i-1][k-1];
        if (pnt <= b && num > ans)
            ans = num;
    }
    cout << ans << endl;
    return 0;
}
0