Submission #420383

# Submission time Handle Problem Language Result Execution time Memory
420383 2021-06-08T10:20:45 Z JvThunder Autobahn (COI21_autobahn) C++14
50 / 100
175 ms 5728 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
typedef long long ll;

using namespace std;

int n,k,x;
int add[1005] = {0};
vector<pair<int,pair<int,int>>> v;
void solve()
{
    cin >> n >> k >> x;
    for(int i=0;i<n;i++)
    {
        int l,t,r;
        cin >> l >> t >> r;
        v.pb({l,{t,r}});
    }

    for(int i=1;i<=1000;i++)
    {
        int extracnt = 0;
        int cnt = 0;
        for(int j=0;j<n;j++)
        {
            if(v[j].fir<=i && i<=v[j].sec.sec) 
            {
                cnt++;
                if(v[j].fir+v[j].sec.fir<=i) extracnt++;
            }
        }
        if(cnt>=k) add[i] = extracnt;
    }

    int sum = 0; int mxsum = 0;
    for(int i=1;i<=x;i++) sum += add[i], mxsum = max(mxsum,sum);
    for(int i=x+1;i<=1000;i++) sum -= add[i-x], sum += add[i], mxsum = max(mxsum,sum);;
    cout << mxsum << endl;
	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int tc=1;
	//cin>>tc;
	for(int i=1;i<=tc;i++) solve();
 	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 4 ms 324 KB Output is correct
13 Correct 3 ms 320 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 4 ms 320 KB Output is correct
16 Correct 3 ms 332 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 4 ms 332 KB Output is correct
19 Correct 3 ms 332 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 4 ms 324 KB Output is correct
13 Correct 3 ms 320 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 4 ms 320 KB Output is correct
16 Correct 3 ms 332 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 4 ms 332 KB Output is correct
19 Correct 3 ms 332 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Runtime error 175 ms 5728 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -