Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;

#define V 6000
#define INF 100000000

typedef pair<int,int> P;
struct edge {
  int to,cap,cost,rev;
  edge(int a,int b,int c,int d){to = a;cap = b,cost = c;rev = d;}
};

int n,m[110],g,a,b;
int x[110][30],y[110][30],c[110][30];
vector<int> time[30];

vector<edge> G[V];
//int h[V];
int dist[V];
int prevv[V], preve[V];

void add_edge(int from,int to,int cap,int cost){
  G[from].push_back(edge(to,cap,cost,G[to].size()));
  G[to].push_back(edge(from,0,-cost,G[from].size() - 1));
}
/*
int min_cost_flow(int s,int t,int f){
  int res = 0;
  fill(h,h+V,0);
  while(f>0){
    priority_queue<P ,vector<P>, greater<P> > q;
    fill(dist,dist+V,INF);
    dist[s] = 0;
    q.push(P(0,s));
    while(!q.empty()){
      P p = q.top(); q.pop();
      int v = p.second;
      if(dist[v] < p.first)continue;
      for(int i=0;i<G[v].size();i++){
	edge &e = G[v][i];
	if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
	  dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
	  prevv[e.to] = v;
	  preve[e.to] = i;
	  q.push(P(dist[e.to],e.to));
	}
      }
    }
    if(dist[t] == INF)return -1;

    for(int v=0;v<V;v++)h[v] += dist[v];

    int d = f;
    for(int v=t;v!=s;v = prevv[v]){
      d = min(d,G[prevv[v]][preve[v]].cap);
    }

    f -= d;
    res += d*h[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}
*/

int min_cost_flow(int s,int t,int f){
  int res = 0;
  while(f>0){
    fill(dist,dist+V,INF);
    dist[s] = 0;
    bool up = true;
    while(up){
      up = false;
      for(int v=0;v<V;v++){
	if(dist[v] == INF)continue;
	for(int i=0;i<G[v].size();i++){
	  edge &e = G[v][i];
	  if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
	    dist[e.to] = dist[v] + e.cost;
	    prevv[e.to] = v;
	    preve[e.to] = i;
	    up = true;
	  }
	}
      }
    }

    if(dist[t] == INF)return -1;

    int d = f;
    for(int v=t;v!=s;v = prevv[v]){
      d = min(d,G[prevv[v]][preve[v]].cap);
    }

    f -= d;
    res += d*dist[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main(){
  while(scanf("%d",&n) != EOF, n){
    m[0] = 1; time[0].clear(); time[0].push_back(0);
    x[0][0] = 0; y[0][0] = 0; c[0][0] = 0;
    for(int i=1;i<n;i++){
      scanf("%d",&m[i]);
      for(int j=0;j<m[i];j++){
	scanf("%d %d %d",&x[i][j],&y[i][j],&c[i][j]);
	time[i].push_back(y[i][j]);
      }
      sort(time[i].begin(),time[i].end());
      time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
    }
    m[n] = 1; time[n].clear(); time[n].push_back(INF);
    x[n][0] = INF; y[n][0] = INF; c[n][0] = 0;
    scanf("%d",&g);

    for(int ans = g;ans>=0;ans--){
      for(int i=0;i<=V;i++)G[i].clear();
      for(int i=0;i<n;i++){
	for(int j=0;j<time[i].size();j++){
	  for(int k=0;k<m[i+1];k++){
	    if(time[i][j]<=x[i+1][k]){
	      for(int l=0;l<time[i+1].size();l++){
		if(y[i+1][k] == time[i+1][l]){
		  a = l;
		  break;
		}
	      }
	      add_edge(i*50 + j*2 + 1, (i+1)*50 + a*2, g, c[i+1][k]);
	    }
	  }
	}
	for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
      }
      /*
      if(ans == g){
	for(int i=0;i<V;i++){
	  for(int j=0;j<G[i].size();j++){
	    edge e = G[i][j];
	    cout << i << " " << e.to << " " << e.cap << " " << e.cost << endl;
	  }
	}
      }
      */

      int res = min_cost_flow(1,n*50,ans);
      if(0<=res){
	cout << ans << " " << res << endl;
	break;
      }
    }
  }
}

Compiler output:
a.cc:20:20: error: 'std::vector<int> time [30]' redeclared as different kind of entity
   20 | vector<int> time[30];
      |                    ^
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:117:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  117 |     m[0] = 1; time[0].clear(); time[0].push_back(0);
      |                     ^
a.cc:117:23: error: request for member 'clear' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  117 |     m[0] = 1; time[0].clear(); time[0].push_back(0);
      |                       ^~~~~
a.cc:117:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  117 |     m[0] = 1; time[0].clear(); time[0].push_back(0);
      |                                      ^
a.cc:117:40: error: request for member 'push_back' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  117 |     m[0] = 1; time[0].clear(); time[0].push_back(0);
      |                                        ^~~~~~~~~
a.cc:123:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  123 |         time[i].push_back(y[i][j]);
      |               ^
a.cc:123:17: error: request for member 'push_back' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  123 |         time[i].push_back(y[i][j]);
      |                 ^~~~~~~~~
a.cc:125:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  125 |       sort(time[i].begin(),time[i].end());
      |                  ^
a.cc:125:20: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  125 |       sort(time[i].begin(),time[i].end());
      |                    ^~~~~
a.cc:125:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  125 |       sort(time[i].begin(),time[i].end());
      |                                  ^
a.cc:125:36: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  125 |       sort(time[i].begin(),time[i].end());
      |                                    ^~~
a.cc:126:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  126 |       time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
      |             ^
a.cc:126:15: error: request for member 'erase' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  126 |       time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
      |               ^~~~~
a.cc:126:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  126 |       time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
      |                                  ^
a.cc:126:36: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  126 |       time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
      |                                    ^~~~~
a.cc:126:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  126 |       time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
      |                                                  ^
a.cc:126:52: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  126 |       time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
      |                                                    ^~~
a.cc:126:65: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  126 |       time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
      |                                                                 ^
a.cc:126:67: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  126 |       time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
      |                                                                   ^~~
a.cc:128:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  128 |     m[n] = 1; time[n].clear(); time[n].push_back(INF);
      |                     ^
a.cc:128:23: error: request for member 'clear' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  128 |     m[n] = 1; time[n].clear(); time[n].push_back(INF);
      |                       ^~~~~
a.cc:128:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  128 |     m[n] = 1; time[n].clear(); time[n].push_back(INF);
      |                                      ^
a.cc:128:40: error: request for member 'push_back' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  128 |     m[n] = 1; time[n].clear(); time[n].push_back(INF);
      |                                        ^~~~~~~~~
a.cc:135:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  135 |         for(int j=0;j<time[i].size();j++){
      |                             ^
a.cc:135:31: error: request for member 'size' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  135 |         for(int j=0;j<time[i].size();j++){
      |                               ^~~~
a.cc:137:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  137 |             if(time[i][j]<=x[i+1][k]){
      |                      ^
a.cc:137:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  137 |             if(time[i][j]<=x[i+1][k]){
      |                         ^
a.cc:137:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  137 |             if(time[i][j]<=x[i+1][k]){
      |                ~~~~~~~~~~^~~~~~~~~~~
a.cc:138:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  138 |               for(int l=0;l<time[i+1].size();l++){
      |                                     ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:138:39: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  138 |               for(int l=0;l<time[i+1].size();l++){
      |                                       ^~~~
a.cc:139:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  139 |                 if(y[i+1][k] == time[i+1][l]){
      |                                         ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:139:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  139 |                 if(y[i+1][k] == time[i+1][l]){
      |                                            ^
a.cc:139:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  139 |                 if(y[i+1][k] == time[i+1][l]){
      |                    ~~~~~~~~~~^~~~~~~~~~~~~~~
a.cc:148:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  148 |         for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
      |                               ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:148:33: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
  148 |         for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
      |                                 ^~~~