답안 #467196

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467196 2021-08-22T02:58:51 Z julian33 Autobahn (COI21_autobahn) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
    cerr<<vars<<" = ";
    string delim="";
    (...,(cerr<<delim<<values,delim=", "));
    cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif

#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);} 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mxN=2e5+5; //make sure this is right
const int mod=1e9+7;

int a[mxN],add[mxN],sub[mxN],bad[mxN],good[mxN],yes[mxN],get_ans[mxN];
int total=0;
int pay=0;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int n,k,x; cin>>n>>k>>x;
    for(int i=0;i<n;i++){
        int l,t,r; cin>>l>>t>>r;
        add[l]++;
        sub[r+1]++;
        if(l+t<=r){
            bad[l+t]++;
            good[r+1]++;
        }
    }
    for(int i=1;i<=1000;i++){
        total+=add[i];
        total-=sub[i];
        pay+=bad[i];
        pay-=good[i];
        if(total>=k){
            yes[i]=1;
            a[i]=pay;
        }
        a[i]+=a[i-1];
    }
    for(int i=1;i<=1000;i++){
        if(yes[i] && (!yes[i-1] || !yes[i+1]))
            get_ans[i]=1;
    }
    int ans=0;
    for(int i=x;i<=1000;i++){
        if(get_ans[i] || get_ans[i-x+1])
            maxa(ans,a[i]-a[i-x]);
    }
    cout<<ans<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -