ProgMe

Untitled

Jun 7th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4.  
  5. //#define FILE 10
  6. #define int int64_t
  7.  
  8. using namespace std;
  9. using namespace __gnu_pbds;
  10.  
  11. template<typename T>
  12. using orset = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  13. template<typename T, typename K>
  14. using ormap = tree <T, K, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  15. mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
  16.  
  17. void solve()
  18. {
  19. int n, m, k;
  20. cin >> n >> m >> k;
  21. int now = n / m;
  22. int mod = n % m;
  23. vector <int> cnt (m);
  24. for (int i = 0; i < m; i++)
  25. cnt [i] = 0;
  26. for (int i = 1; i <= min(m, n); i++)
  27. {
  28. if (m == i)
  29. {
  30. cnt [0] = now;
  31. if (mod)
  32. {
  33. cnt [0]++;
  34. mod--;
  35. }
  36. continue;
  37. }
  38. cnt [i] = now;
  39. if (mod)
  40. {
  41. cnt [i]++;
  42. mod--;
  43. }
  44. }
  45. int sum = 0;
  46. int i = 0;
  47. for (; i < m; i++)
  48. {
  49. sum += cnt [i];
  50. if (sum >= k)
  51. break;
  52. }
  53. cout << i << "\n";
  54. }
  55.  
  56. int32_t main(int32_t argc, char* argv[]) {
  57. ios::sync_with_stdio(false);
  58. cin.tie(0);cout.tie(0);
  59. #ifdef FILE
  60. freopen("input.txt", "r", stdin);
  61. freopen("output.txt", "w", stdout);
  62. #endif
  63. int t = 1;
  64. //cin >> t;
  65. while (t--)
  66. solve();
  67. }
Advertisement
Add Comment
Please, Sign In to add comment