Advertisement
STANAANDREY

AOCMMXX d10p1/2

Dec 13th, 2020 (edited)
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int k, v[100], fr[4];
  4. uint64_t dp[100];
  5. //dp[i]-nr of combinations until position i
  6.  
  7. int main() {
  8.     freopen("text.in", "r", stdin);
  9.     while (cin >> v[++k]);
  10.     k--;
  11.     sort(v + 1, v + k + 1);
  12.     for (int i = 0; i < k; i++) {
  13.         fr[v[i + 1] - v[i]]++;
  14.     }
  15.     fr[3]++;
  16.     cout << fr[1] * fr[3] << endl;
  17.     //part2
  18.     dp[0] = 1;
  19.     for (int i = 1; i <= k; i++) {
  20.         for (int j = i - 1; j >= 0; j--) {
  21.             if (v[i] - v[j] > 3)
  22.                 break;
  23.             dp[i] += dp[j];
  24.         }
  25.     }
  26.     cout << dp[k] << endl;
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement