比赛 EYOI常规赛 1st 评测结果 AAAAAAAAAAAAAAAAAAAAAAAAA
题目名称 EYOI的成立 最终得分 100
用户昵称 yrtiop 运行时间 0.724 s
代码语言 C++ 内存使用 4.99 MiB
提交时间 2021-12-15 20:02:25
显示代码纯文本
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <algorithm>
  4. #include <cctype>
  5. using namespace std;
  6. const int N = 1000000;
  7. int c[N + 5];
  8. int lowbit(int x) {
  9. return x & -x;
  10. }
  11. void modify(int x,int y) {
  12. if(!x)return ;
  13. for(;x <= N;x += lowbit(x))c[x] = max(c[x] , y);
  14. return ;
  15. }
  16. int query(int x) {
  17. if(x <= 0)return 0;
  18. int ans = 0;
  19. for(;x;x -= lowbit(x))ans = max(ans , c[x]);
  20. return ans;
  21. }
  22. int main() {
  23. freopen("EYOI_found.in","r",stdin);
  24. freopen("EYOI_found.out","w",stdout);
  25. int n;
  26. scanf("%d",&n);
  27. for(int i = 1;i <= n;++ i) {
  28. int x,y;
  29. scanf("%d%d",&x,&y);
  30. printf("%d ",query(x + y - 1));
  31. modify(x , x);
  32. }
  33. fclose(stdin);
  34. fclose(stdout);
  35. return 0;
  36. }