結果

問題 No.777 再帰的ケーキ
ユーザー chocoruskchocorusk
提出日時 2018-12-24 00:26:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 1,186 bytes
コンパイル時間 1,871 ms
コンパイル使用メモリ 95,120 KB
実行使用メモリ 28,432 KB
最終ジャッジ日時 2023-10-26 02:51:43
合計ジャッジ時間 7,416 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
14,856 KB
testcase_01 AC 9 ms
14,856 KB
testcase_02 AC 9 ms
14,856 KB
testcase_03 AC 8 ms
14,856 KB
testcase_04 AC 9 ms
14,856 KB
testcase_05 AC 9 ms
14,856 KB
testcase_06 AC 9 ms
14,860 KB
testcase_07 AC 9 ms
14,860 KB
testcase_08 AC 10 ms
14,856 KB
testcase_09 AC 9 ms
14,856 KB
testcase_10 AC 9 ms
14,856 KB
testcase_11 AC 9 ms
14,856 KB
testcase_12 AC 9 ms
14,860 KB
testcase_13 AC 9 ms
14,860 KB
testcase_14 AC 9 ms
14,860 KB
testcase_15 AC 8 ms
14,856 KB
testcase_16 AC 9 ms
14,856 KB
testcase_17 AC 9 ms
14,856 KB
testcase_18 AC 9 ms
14,860 KB
testcase_19 AC 9 ms
14,860 KB
testcase_20 AC 9 ms
14,860 KB
testcase_21 AC 12 ms
15,000 KB
testcase_22 AC 11 ms
15,000 KB
testcase_23 AC 10 ms
14,856 KB
testcase_24 AC 9 ms
14,856 KB
testcase_25 AC 13 ms
15,000 KB
testcase_26 AC 12 ms
15,000 KB
testcase_27 AC 11 ms
14,856 KB
testcase_28 AC 524 ms
28,432 KB
testcase_29 AC 524 ms
28,432 KB
testcase_30 AC 548 ms
28,432 KB
testcase_31 AC 553 ms
28,432 KB
testcase_32 AC 323 ms
28,432 KB
testcase_33 AC 121 ms
14,856 KB
testcase_34 AC 178 ms
14,856 KB
testcase_35 AC 397 ms
21,772 KB
testcase_36 AC 321 ms
28,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> Pi;
ll bit[200001]; int n1;
ll mx[200001];
ll max(int i){
	ll s=0;
	while(i>0){
		s=max(s, bit[i]);
		i-=(i&(-i));
	}
	return s;
}
void update(int i, ll x){
  if(mx[i]>=x) return;
  mx[i]=x;
	while(i<=n1){
		bit[i]=max(bit[i], x);
		i+=(i&(-i));
	}
}
int main()
{
	int n; cin>>n;
  ll a[200000], b[200000], c[200000];
  Pi p[200000];
  for(int i=0; i<n; i++){
    cin>>a[i]>>b[i]>>c[i];
    p[i]=Pi(P(a[i], b[i]), c[i]);
  }
  sort(p, p+n, [](Pi x, Pi y){ if(x.first.first!=y.first.first) return x.first.first<y.first.first; else return x.first.second>y.first.second;});
  map<ll, int> mp;
  for(int i=0; i<n; i++){
    mp[p[i].first.second]=0;
  }
  int m=1;
  for(auto& q:mp){
    q.second=m;
    m++;
  }
  m--;
  n1=m;
  for(int i=0; i<n; i++){
    int t=mp[p[i].first.second];
    update(t, max(t-1)+p[i].second);
  }
  cout<<max(m)<<endl;
	return 0;
}
0