Submission #154109

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1541092019-09-18 11:19:18beso123Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
64 / 100
3020 ms84076 KiB
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+9;
int w[N], l[N], n, m,ans[N], L[N], R[N], F[N];
set<int > s;
void ad(int l, int r){
auto it = s.lower_bound(l);
if(it != s.end() && F[*it] <= r) return;
while(it != s.begin() && F[*(--it)] >= r){
s.erase(it);
it = s.lower_bound(l);
}
F[l] =r;
s.insert(l);
}
main(){
int n;
cin >> n >> m;
for(int i = 1; i <= n; i++){
scanf("%d",&w[i]);
}
stack<int> S;
for(int i = 1; i <= n; i++){
while(S.size() && w[S.top()] <= w[i]) S.pop();
if(!S.size()) l[i] = 0;
else l[i] = S.top();
S.push(i);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

sortbooks.cpp:17:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:44:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < Q.size(); i++){
                    ~~^~~~~~~~~~
sortbooks.cpp:45:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(j < v.size() && v[j].first < Q[i].first){
               ~~^~~~~~~~~~
sortbooks.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&w[i]);
         ~~~~~^~~~~~~~~~~~
sortbooks.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &L[i],&R[i], &k);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...