Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // массивы индексируются с 1
- // r[i] - внутренние радиусы
- // d[i] - внешние радиусы дисков
- // n - количество
- rMax = new int[n + 1];
- rMax[1] = r[1];
- for (int i = 2; i <= n; i++)
- rMax[i] = Math.min(rMax[i - 1], r[i]);
- int curIt = n;
- int ans = 0;
- for (int i = 1; i <= n; i++) {
- int nextR = d[i];
- while (curIt >= 1 && rMax[curIt] < nextR) curIt--;
- if (curIt == 0) break;
- ans++;
- curIt--;
- }
- out.println(ans);
Advertisement
Add Comment
Please, Sign In to add comment