Submission #134130

# Submission time Handle Problem Language Result Execution time Memory
134130 2019-07-22T06:23:44 Z dragonslayerit Global Warming (CEOI18_glo) C++14
100 / 100
633 ms 24956 KB
#include <cstdio>
#include <algorithm>
#include <map>

const int INF=1e9+7;

int ts[200005];

int lis[400005];
int lisd[400005];

void update(int* ft,int i,int v){
  for(;i<=400004;i+=(i&-i)){
    ft[i]=std::max(ft[i],v);
  }
}

int query(int* ft,int i){
  int ac=0;
  for(;i>0;i-=(i&-i)){
    ac=std::max(ac,ft[i]);
  }
  return ac;
}

int main(){
  int N,X;
  scanf("%d %d",&N,&X);
  std::map<int,int> cps;
  for(int i=0;i<N;i++){
    scanf("%d",&ts[i]);
    cps[ts[i]];
    cps[ts[i]+X];
  }
  {
    int last=1;
    for(auto& it:cps){
      it.second=last++;
    }
  }
  for(int i=0;i<N;i++){
    int x=cps[ts[i]],y=cps[ts[i]+X];
    update(lisd,x,1+query(lisd,x-1));
    update(lisd,x,1+query(lis,y-1));
    update(lis,x,1+query(lis,x-1));
  }
  printf("%d\n",query(lisd,400004));
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&N,&X);
   ~~~~~^~~~~~~~~~~~~~~
glo.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&ts[i]);
     ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 4 ms 476 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 3 ms 504 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 404 ms 14052 KB Output is correct
2 Correct 456 ms 14072 KB Output is correct
3 Correct 386 ms 14072 KB Output is correct
4 Correct 400 ms 14056 KB Output is correct
5 Correct 159 ms 7800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 6520 KB Output is correct
2 Correct 102 ms 6564 KB Output is correct
3 Correct 99 ms 6520 KB Output is correct
4 Correct 42 ms 3576 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 45 ms 3576 KB Output is correct
7 Correct 65 ms 5624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 296 ms 11996 KB Output is correct
2 Correct 296 ms 12048 KB Output is correct
3 Correct 633 ms 23544 KB Output is correct
4 Correct 235 ms 12480 KB Output is correct
5 Correct 139 ms 11512 KB Output is correct
6 Correct 284 ms 21692 KB Output is correct
7 Correct 288 ms 22208 KB Output is correct
8 Correct 187 ms 11992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 4 ms 476 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 3 ms 504 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 404 ms 14052 KB Output is correct
28 Correct 456 ms 14072 KB Output is correct
29 Correct 386 ms 14072 KB Output is correct
30 Correct 400 ms 14056 KB Output is correct
31 Correct 159 ms 7800 KB Output is correct
32 Correct 92 ms 6520 KB Output is correct
33 Correct 102 ms 6564 KB Output is correct
34 Correct 99 ms 6520 KB Output is correct
35 Correct 42 ms 3576 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 45 ms 3576 KB Output is correct
38 Correct 65 ms 5624 KB Output is correct
39 Correct 296 ms 11996 KB Output is correct
40 Correct 296 ms 12048 KB Output is correct
41 Correct 633 ms 23544 KB Output is correct
42 Correct 235 ms 12480 KB Output is correct
43 Correct 139 ms 11512 KB Output is correct
44 Correct 284 ms 21692 KB Output is correct
45 Correct 288 ms 22208 KB Output is correct
46 Correct 187 ms 11992 KB Output is correct
47 Correct 221 ms 12672 KB Output is correct
48 Correct 235 ms 12808 KB Output is correct
49 Correct 633 ms 24956 KB Output is correct
50 Correct 164 ms 13304 KB Output is correct
51 Correct 166 ms 9872 KB Output is correct
52 Correct 226 ms 13432 KB Output is correct
53 Correct 303 ms 22776 KB Output is correct
54 Correct 312 ms 23416 KB Output is correct
55 Correct 365 ms 21496 KB Output is correct