結果

問題 No.844 split game
ユーザー sinsincoscos
提出日時 2019-03-13 22:09:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 775 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 67,236 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-06-24 14:58:01
合計ジャッジ時間 4,557 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 1 WA * 1 TLE * 1 -- * 53
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int N,M,L[100010],R[100010];
ll A,P[100010];


int main(){
    cin >> N >> M >> A;
    for(int i=0;i<M;i++){
        cin >> L[i] >> R[i] >> P[i];
    }
    ll ans = 0;
    for(int S=0;S<(1<<(N+1));S++){
        ll now = -A*(__builtin_popcount(S)-2);
        if(!(S&(1<<0)) || !(S&(1<<N))) continue;
        for(int i=0;i<M;i++){
            if(!(S&(1<<(L[i]-1))) || !(S&(1<<(R[i])))) continue;
            bool judge = true;
            for(int j=L[i];j<R[i];j++){
                if(S&(1<<j)){
                    judge = false;
                    break;
                }
            }
            if(judge) now += P[i];
        }
        ans = max(ans,now);
    }
    cout << ans << endl;
}
0