Submission #1116078

# Submission time Handle Problem Language Result Execution time Memory
1116078 2024-11-21T08:44:33 Z SalihSahin Autobahn (COI21_autobahn) C++14
50 / 100
70 ms 21448 KB
#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;

const int inf = 1e16;
const int N = 1e3 + 5;

int32_t main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0); cout.tie(0);
   int n, k, x;
   cin>>n>>k>>x;
   vector<array<int, 3> > upd;

   for(int i = 0; i < n; i++){
      int l, t, r;
      cin>>l>>t>>r;

      if(r - l + 1 > t){
         upd.pb({l, i, 0});
         upd.pb({l+t, i, 1});
         upd.pb({r+1, i, 2});
      }
      else{
         upd.pb({l, i, 0});
         upd.pb({r+1, i, 2});
      }
   }

   sort(upd.begin(), upd.end());
   vector<int> col(n); // 0 yok, 1 iceride, 2 oduyor
   vector<int> odeme(N);
   int act = 0, ode = 0, ind = 0;

   for(int i = 0; i <= N; i++){
      while(ind < upd.size() && upd[ind][0] <= i){
         if(upd[ind][2] == 0){
            act++;
            col[upd[ind][1]] = 1;
         }
         else if(upd[ind][2] == 1){
            col[upd[ind][1]] = 2;
            ode++;
         }
         else{
            if(col[upd[ind][1]] == 2) ode--;
            act--;
            col[upd[ind][1]] = 0;
         }
         ind++;
      }

      if(act >= k) odeme[i] = ode;
   }

   int hh = 0;
   for(int i = 0; i < x; i++){
      hh += odeme[i];
   }
   int ans = hh;
   for(int i = x; i < N; i++){
      hh += odeme[i];
      hh -= odeme[i - x];
      ans = max(ans, hh);
   }

   cout<<ans<<endl;
   return 0;
}

Compilation message

autobahn.cpp: In function 'int32_t main()':
autobahn.cpp:37:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |       while(ind < upd.size() && upd[ind][0] <= i){
      |             ~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 2 ms 592 KB Output is correct
14 Correct 2 ms 464 KB Output is correct
15 Correct 2 ms 592 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 2 ms 592 KB Output is correct
19 Correct 2 ms 592 KB Output is correct
20 Correct 2 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 2 ms 592 KB Output is correct
14 Correct 2 ms 464 KB Output is correct
15 Correct 2 ms 592 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 2 ms 592 KB Output is correct
19 Correct 2 ms 592 KB Output is correct
20 Correct 2 ms 592 KB Output is correct
21 Runtime error 70 ms 21448 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -