fork download
  1. #include<bits/stdc++.h>
  2. #define f1(i, n) for(ll i=1;i<=n;++i)
  3. #define f0(i, n) for(ll i=0;i<n;++i)
  4. #define ull unsigned long long
  5. #define ll long long
  6. #define rev(a) reverse(a.begin(),a.end())
  7. #define all(x) x.begin(),x.end()
  8. #define so(A, n) sort(A+1, A+n+1)
  9. using namespace std;
  10. const int maxn = 200010;
  11. const int N = 1e6 + 1;
  12. void solve1() {
  13. ll x1, x2, x3, x4;
  14. ll y, res = 0;
  15. cin >> x1 >> x2 >> x3 >> x4 >> y;
  16. res += (min(y, 50ll) * x1); y = max(0ll, y - 50);
  17. res += (min(y, 50ll) * x2); y = max(0ll, y - 50);
  18. res += (min(y, 100ll) * x3); y = max(0ll, y - 100);
  19. res += y * x4;
  20. cout << res;
  21. }
  22. int D[N];
  23. void sanguoc() {
  24. for (int i = 1; i <= sqrt(N); ++i) {
  25. for (int j = 1; j <= N / i; ++j) {
  26. D[j * i]++;
  27. }
  28. }
  29. }
  30. void solve2() {
  31. sanguoc();
  32. int n;
  33. cin >> n;
  34. int res = 0, x;
  35. f1(i, n) {cin >> x; res = max(res, D[x]);}
  36. cout << res;
  37. }
  38. void solve3() {
  39. ll sum = 0;
  40. ll n, chan = 0, le = 0, x;
  41. cin >> n;
  42. f1(i, n) {
  43. cin >> x;
  44. if (x % 2 == 0) chan++;
  45. else le++;
  46. sum += x;
  47. }
  48. if (sum % 2 == 0) {
  49. cout << (chan * (chan - 1) / 2) + (le * (le - 1) / 2);
  50. }
  51. else {
  52. cout << le * chan;
  53. }
  54. }
  55. void solve4() {
  56. ll n, k;
  57. cin >> n >> k;
  58. map<int, int> y;
  59. int x[n + 1];
  60. f1(i, n) {
  61. cin >> x[i] >> y[x[i]];
  62. }
  63. if (n <= 1e3) {
  64. int cnt, ma = 0;
  65. for (int i = 1; i <= 1e3; ++i) {
  66. cnt = 0;
  67. for (int j = max(1ll, i - k); j <= i + k; ++j) {
  68. cnt += y[j];
  69. }
  70. ma = max(ma, cnt);
  71. }
  72. cout << ma;
  73. }
  74. else
  75. {
  76. ll T[n + 1];
  77. T[0] = 0;
  78. sort(x + 1, x + n + 1);
  79. f1(i, n) T[i] = T[i - 1] + y[x[i]];
  80. ll ma = 0;
  81. for (int i = 1; i <= n; ++i) {
  82. int vt = upper_bound(x + 1, x + n + 1, x[i] + 2 * k) - x - 1;
  83. ma = max(ma, T[vt] - T[i - 1]);
  84. }
  85. cout << ma;
  86. }
  87. }
  88. int main()
  89. {
  90. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  91.  
  92. // freopen("pay.inp","r",stdin);
  93. // freopen("pay.out","w",stdout);
  94. // solve1();
  95. // solve2();
  96. // solve3();
  97. // solve4();
  98.  
  99. return 0;
  100. }
  101.  
  102.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty