Submission #152319

#TimeUsernameProblemLanguageResultExecution timeMemory
152319KalamHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++11
100 / 100
1458 ms104128 KiB
// KALAM # include<bits/stdc++.h> using namespace std; const int N = 1000000 + 77 , inf = 1000000000 + 77; int n , q , a[N] , L[N] , Fen[N]; int Ql[N] , Qr[N] , Qk[N]; int A[N]; vector < int > Q[N]; inline void Update(int x , int y) { x = N - x - 10; for(;x < N;x += x & - x) if(y > Fen[x]) Fen[x] = y; } inline int Get(int x) { x = N - x - 10; int res = 0; for(;x;x ^= x & - x) if(res < Fen[x]) res = Fen[x]; return res; } int main() { a[0] = inf; scanf("%d %d" , & n , & q); for(int i = 1;i <= n;++ i) { scanf("%d" , a + i); L[i] = i - 1; while(a[L[i]] <= a[i]) L[i] = L[L[i]]; } for(int i = 1;i <= q;++ i) scanf("%d %d %d" , Ql + i , Qr + i , Qk + i) , Q[Qr[i]].push_back(i); for(int i = 1;i <= n;++ i) { int x = L[i]; if(x) Update(x , a[i] + a[x]); for(int id : Q[i]) A[id] = (Get(Ql[id]) <= Qk[id]); } for(int i = 1;i <= q;++ i) printf("%d\n" , A[i]); return 0; }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:27:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d" , & n , & q);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:29:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d" , a + i);
       ~~~~~^~~~~~~~~~~~~~
sortbooks.cpp:34:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d %d %d" , Ql + i , Qr + i , Qk + i) , Q[Qr[i]].push_back(i);
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...