Submission #4334349


Source Code Expand

Copy
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct Cut{
    ll T;
    ll L;
    ll R;

    Cut(){}
    Cut(ll a, ll b, ll c){
        T = a;
        L = b;
        R = c;
    }
};

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll N, M;
    cin >> N >> M;

    vector<Cut> A(N);
    FOR(i, 0, N){
        ll T, L, R;
        cin >> T >> L >> R;
        A[i] = Cut(T, L, R);
    }
    reverse(ALL(A));
    
    set<ll> S;
    FOR(i, 1, N+1){
        S.insert(i);
    }

    ll score = 0;

    FOR(i, 0, N){
        ll T = A[i].T;
        ll L = A[i].L;
        ll R = A[i].R;

        FOR(j, L, R+1){
            if(S.find(j)!=S.end()){
                score += T;
                S.erase(j);
            }
        }
    }

    p(score);
    
    return 0;
}

Submission Info

Submission Time
Task D - Deforestation
User peroon
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1476 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt
All 0 / 500 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt 1 ms 256 KB
01-02.txt
01-03.txt 168 ms 12544 KB
01-04.txt 57 ms 11136 KB
01-05.txt
01-06.txt
01-07.txt 196 ms 14336 KB
01-08.txt
01-09.txt
sample-01.txt 1 ms 256 KB
sample-02.txt 1 ms 256 KB
sample-03.txt 1 ms 256 KB