Advertisement
isaf27

Global Round 7, solution of the problem C

Mar 19th, 2020
5,227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int MOD = 998244353;
  6.  
  7. int n, k, a;
  8.  
  9. int main()
  10. {
  11.     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  12.     cin >> n >> k;
  13.     int p = -1;
  14.     int ans = 1;
  15.     long long sum = 0;
  16.     for (int i = 0; i < n; i++)
  17.     {
  18.         cin >> a;
  19.         if (a >= n - k + 1)
  20.         {
  21.             if (p != -1)
  22.                 ans = 1LL * ans * (i - p) % MOD;
  23.             sum += a;
  24.             p = i;
  25.         }
  26.     }
  27.     cout << sum << " " << ans << "\n";
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement