Submission #284785

#TimeUsernameProblemLanguageResultExecution timeMemory
284785dantoh000Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
17 / 100
514 ms17052 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; int n,m; int w[5005]; vector<ii> v[5005]; int main(){ scanf("%d%d",&n,&m); if (n > 5000) return 0; for (int i = 1; i <= n; i++) scanf("%d",&w[i]); for (int i = 1; i <= n; i++){ for (int j = i+1; j <= n; j++){ if (w[j] < w[i] && (v[i].size() == 0 || w[j] > v[i].back().second)) v[i].push_back({j,w[j]}); } } for (int i = 0; i < m; i++){ int l,r,k; scanf("%d%d%d",&l,&r,&k); int ans = 1; for (int j = l; j <= r; j++){ int p = upper_bound(v[j].begin(),v[j].end(),ii(r+1,-1))-v[j].begin(); //printf("%d %d -> %d\n",j,w[j],p); if (p == 0){ continue; } else{ p--; if (w[j]+v[j][p].second > k) ans = 0; } } printf("%d\n",ans); } }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
sortbooks.cpp:10:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     for (int i = 1; i <= n; i++) scanf("%d",&w[i]);
      |                                  ~~~~~^~~~~~~~~~~~
sortbooks.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         scanf("%d%d%d",&l,&r,&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...