답안 #420470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
420470 2021-06-08T11:39:31 Z JvThunder Autobahn (COI21_autobahn) C++17
50 / 100
137 ms 2996 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<v.size();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;
}

Compilation message

autobahn.cpp: In function 'void solve()':
autobahn.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for(int j=0;j<v.size();j++)
      |                     ~^~~~~~~~~
# 결과 실행 시간 메모리 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 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 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 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 3 ms 332 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 332 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 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 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 3 ms 332 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 3 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 137 ms 2996 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -