結果

問題 No.759 悪くない忘年会にしような!
ユーザー omochanalomochanal
提出日時 2018-12-20 19:48:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 3,883 bytes
コンパイル時間 1,657 ms
コンパイル使用メモリ 176,692 KB
実行使用メモリ 9,068 KB
最終ジャッジ日時 2023-10-26 01:11:15
合計ジャッジ時間 7,608 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,696 KB
testcase_01 AC 3 ms
5,696 KB
testcase_02 AC 2 ms
5,696 KB
testcase_03 AC 2 ms
5,696 KB
testcase_04 AC 2 ms
5,696 KB
testcase_05 AC 3 ms
5,696 KB
testcase_06 AC 2 ms
5,696 KB
testcase_07 AC 3 ms
5,696 KB
testcase_08 AC 2 ms
5,696 KB
testcase_09 AC 2 ms
5,696 KB
testcase_10 AC 3 ms
5,696 KB
testcase_11 AC 2 ms
5,696 KB
testcase_12 AC 2 ms
5,696 KB
testcase_13 AC 3 ms
5,696 KB
testcase_14 AC 2 ms
5,696 KB
testcase_15 AC 3 ms
5,696 KB
testcase_16 AC 3 ms
5,696 KB
testcase_17 AC 2 ms
5,696 KB
testcase_18 AC 2 ms
5,696 KB
testcase_19 AC 2 ms
5,696 KB
testcase_20 AC 2 ms
5,696 KB
testcase_21 AC 2 ms
5,696 KB
testcase_22 AC 3 ms
5,696 KB
testcase_23 AC 3 ms
5,696 KB
testcase_24 AC 3 ms
5,696 KB
testcase_25 AC 3 ms
5,696 KB
testcase_26 AC 3 ms
5,696 KB
testcase_27 AC 3 ms
5,696 KB
testcase_28 AC 2 ms
5,696 KB
testcase_29 AC 3 ms
5,696 KB
testcase_30 AC 3 ms
5,696 KB
testcase_31 AC 2 ms
5,696 KB
testcase_32 AC 2 ms
5,696 KB
testcase_33 AC 7 ms
5,960 KB
testcase_34 AC 4 ms
5,696 KB
testcase_35 AC 5 ms
5,712 KB
testcase_36 AC 7 ms
5,960 KB
testcase_37 AC 3 ms
5,696 KB
testcase_38 AC 7 ms
5,960 KB
testcase_39 AC 4 ms
5,696 KB
testcase_40 AC 6 ms
5,748 KB
testcase_41 AC 6 ms
6,020 KB
testcase_42 AC 9 ms
5,960 KB
testcase_43 AC 9 ms
5,960 KB
testcase_44 AC 57 ms
8,532 KB
testcase_45 AC 57 ms
8,532 KB
testcase_46 AC 56 ms
8,532 KB
testcase_47 AC 57 ms
8,532 KB
testcase_48 AC 57 ms
8,532 KB
testcase_49 AC 8 ms
5,960 KB
testcase_50 AC 8 ms
5,960 KB
testcase_51 AC 8 ms
5,960 KB
testcase_52 AC 8 ms
5,960 KB
testcase_53 AC 57 ms
8,532 KB
testcase_54 AC 57 ms
8,532 KB
testcase_55 AC 58 ms
8,532 KB
testcase_56 AC 58 ms
8,532 KB
testcase_57 AC 56 ms
8,532 KB
testcase_58 AC 57 ms
8,532 KB
testcase_59 AC 57 ms
8,532 KB
testcase_60 AC 56 ms
8,532 KB
testcase_61 AC 57 ms
8,532 KB
testcase_62 AC 56 ms
8,532 KB
testcase_63 AC 85 ms
9,068 KB
testcase_64 AC 84 ms
9,068 KB
testcase_65 AC 53 ms
8,532 KB
testcase_66 AC 82 ms
9,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

struct T {
	ll v;
	T(ll v = -linf) : v(v) {}
	T operator+(const T& t) { return T(max(v, t.v)); } //when getting value
	void operator+=(const T& t) { v = max(v, t.v); } //when updating value
	friend ostream& operator<<(ostream& out, const T& t) {
		out << t.v; return out;
	}
};

struct segtree { //use BIT if you can
	int n; vector<T> sum, lazy;
	void init(int mx) {
		n = 1;
		while(n < mx) n *= 2;
		sum = vector<T>(n * 2);
		lazy = vector<T>(n * 2);
	}
	segtree(int mx = 0) { init(mx); }
	inline void lazy_eval(int k, int l, int r) {
		if(lazy[k].v != T().v) {
			sum[k * 2 + 1] += lazy[k];
			lazy[k * 2 + 1] += lazy[k];
			sum[k * 2 + 2] += lazy[k];
			lazy[k * 2 + 2] += lazy[k];
			lazy[k] = T();
		}
	}
	void app(int a, int b, T s, int k, int l, int r) {
		if(b <= l || r <= a) return;
		if(a <= l && r <= b) {
			sum[k] += s; //here too
			lazy[k] += s;
		}
		else {
			lazy_eval(k, l, r);
			app(a, b, s, k * 2 + 1, l, (l + r) / 2);
			app(a, b, s, k * 2 + 2, (l + r) / 2, r);
			sum[k] = sum[k * 2 + 1] + sum[k * 2 + 2];
		}
	}
	T ga(int a, int b, int k, int l, int r) {
		if(b <= l || r <= a) return T();
		if(a <= l && r <= b) return sum[k];
		else {
			lazy_eval(k, l, r);
			T lv = ga(a, b, k * 2 + 1, l, (l + r) / 2);
			T rv = ga(a, b, k * 2 + 2, (l + r) / 2, r);
			return lv + rv;
		}
	}
	void show() {
		vector<T> tmp;
		rep(i, 0, n) tmp.push_back(get(i, i + 1));
		debug(tmp);
	}
	T get(int a, int b) { return ga(a, b, 0, 0, n); } //[a, b)
	void update(int a, int b, T s) { app(a, b, s, 0, 0, n); } //[a, b)
};

int N;
pair<tuple<int, int, int>, int> P[MAX_N];
segtree seg;

void solve() {
	cin >> N;
	rep(i, 0, N) {
		int a, b, c; cin >> a >> b >> c;
		P[i] = make_pair(make_tuple(-a, -b, -c), i);
	}
	sort(P, P + N);

	seg.init(10010);
	vi ans;
	rep(i, 0, N) {
		int x = get<1>(P[i].fst) * -1;
		int y = get<2>(P[i].fst) * -1;
		int idx = P[i].sec;
		if(seg.get(x, x + 1).v < y) {
			ans.pb(idx);
			seg.update(0, x + 1, T(y));
		}
	}
	sort(all(ans));
	rep(i, 0, sz(ans)) {
		cout << ans[i] + 1 << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

0