답안 #1002630

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1002630 2024-06-19T17:12:09 Z Lalic Autobahn (COI21_autobahn) C++17
0 / 100
1 ms 464 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;

const int MAXN = 1e5+10;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);

ll arr[MAXN], spec[MAXN];

void solve(){
	int n, k, x; cin >> n >> k >> x;
	
	int lim=-1;
	for(int i=0;i<n;i++){
		int l, t, r; cin >> l >> t >> r;
		if(l+t<=r){
			arr[l]++;
			arr[r+1]--;
			if(l+t<=r){
				spec[l+t]++;
				spec[r+1]--;
			}
		}
		lim=max(lim, r);
	}
	
	for(int i=1;i<=lim;i++) arr[i]+=arr[i-1];
	for(int i=1;i<=lim;i++) spec[i]+=spec[i-1];
	
	ll ptr=1, curr=0, ans=0;
	for(int i=1;i<=lim;i++){
		while(ptr<=lim && ptr-i<x){
			if(arr[ptr]>=k) curr+=spec[ptr];
			ptr++;
		}
		ans=max(ans, curr);
		if(arr[i]>=k) curr-=spec[i];
	}
		
	cout << ans << "\n";	
}

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int tt=1;
	//~ cin >> tt;
	while(tt--) solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -