Niestety, nie byliśmy w stanie w pełni poprawnie wyświetlić tego pliku, ponieważ nie jest zakodowany w UTF-8. Możesz pobrać ten plik i spróbować otworzyć go samodzielnie.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
using namespace std;

const int modulo = 1000000000 + 7;
const int PLAYERS = 1000000;

struct Players0 {
  int teams;
  int times;
};

Players0 players0[PLAYERS+1];
int size0[PLAYERS][2];

int main() {
  ios_base::sync_with_stdio(0);
  int n;

  cin >> n;
  for(int i = 0; i < n; ++i)
    cin >> size0[i][0] >> size0[i][1];

  players0[0].teams = 0;
  players0[0].times = 1;
  for(int i = 0; i < n; ++i) {                // dla ka�dego zawodnika;
    if(players0[i].times <= 0)
      continue;
    int teams = players0[i].teams + 1;
    int min_size = 0;
    int max_size = n - i;
    for(int j = 0; j < max_size && min_size <= max_size; ) {  // dla ka�dej wielko�ci dru�yny;
      if(min_size < size0[i+j][0])
        min_size = size0[i+j][0];
      if(max_size > size0[i+j][1])
        max_size = size0[i+j][1];
      if(++j >= min_size && j <= max_size) {
        if(players0[i+j].teams < teams) {
          players0[i+j].teams = teams;
          players0[i+j].times = players0[i].times;
        }
        else {
          players0[i+j].times += players0[i].times;
          if(players0[i+j].times >= modulo)
            players0[i+j].times -= modulo;
        }
      }
    }
  }
  if(players0[n].times > 0)
    cout << players0[n].teams << ' ' << players0[n].times << '\n';
  else
    cout << "NIE\n";
  return 0;
}