Submission #467205

# Submission time Handle Problem Language Result Execution time Memory
467205 2021-08-22T03:10:32 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]=pay;
            a[i]=pay;
        }
        a[i]+=a[i-1];
    }
    for(int i=1;i<=1000;i++){
        if(yes[i]>yes[i-1])
            get_ans[i]=1;
    }
    int ans=a[x];
    for(int i=x;i<=1000;i++){
        if(get_ans[i])
            maxa(ans,a[i]-a[i-x]);
    }
    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -