이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e5+5;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define fr first
#define sc second
int n, k, x, qtd[MAXN], val[MAXN];
ll pref[MAXN];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k >> x;
for(int i = 0, a, b, c; i < n; i++) {
cin >> a >> c >> b;
qtd[a]++;
qtd[b+1]--;
val[a+c]++;
val[b+1]--;
}
for(int i = 1; i <= 1000; i++) qtd[i] += qtd[i-1];
for(int i = 1; i <= 1000; i++){
val[i] += val[i-1];
if(qtd[i] < k) pref[i] = pref[i-1];
else pref[i] = pref[i-1] + val[i];
}
ll ans = 0;
for(int i = 1; i <= 1000; i++)
ans = max(ans, pref[i+x-1] - pref[i-1]);
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |