比赛 |
EYOI常规赛 1st |
评测结果 |
AAAAAAAAAAAAAAAAAAAAAAAAA |
题目名称 |
EYOI的成立 |
最终得分 |
100 |
用户昵称 |
yrtiop |
运行时间 |
0.724 s |
代码语言 |
C++ |
内存使用 |
4.99 MiB |
提交时间 |
2021-12-15 20:02:25 |
显示代码纯文本
- #include <cstdio>
- #include <cstring>
- #include <algorithm>
- #include <cctype>
- using namespace std;
- const int N = 1000000;
- int c[N + 5];
- int lowbit(int x) {
- return x & -x;
- }
- void modify(int x,int y) {
- if(!x)return ;
- for(;x <= N;x += lowbit(x))c[x] = max(c[x] , y);
- return ;
- }
- int query(int x) {
- if(x <= 0)return 0;
- int ans = 0;
- for(;x;x -= lowbit(x))ans = max(ans , c[x]);
- return ans;
- }
- int main() {
- freopen("EYOI_found.in","r",stdin);
- freopen("EYOI_found.out","w",stdout);
- int n;
- scanf("%d",&n);
- for(int i = 1;i <= n;++ i) {
- int x,y;
- scanf("%d%d",&x,&y);
- printf("%d ",query(x + y - 1));
- modify(x , x);
- }
- fclose(stdin);
- fclose(stdout);
- return 0;
- }