Submission #1276441

#TimeUsernameProblemLanguageResultExecution timeMemory
1276441nanaseyuzukiHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
100 / 100
565 ms63668 KiB
#include <bits/stdc++.h> // Author: Kazuki_Will_Win_VOI_8703 #define fi first #define se second #define pii pair<int, int> #define ll long long #define all(a) a.begin(), a.end() using namespace std; const int mn = 1e6 + 5; int n, m, a[mn], rev[mn], pre[mn], ans[mn]; int bit[mn]; void add(int u, int val){ while(u){ bit[u] = max(bit[u], val); u -= (u & -u); } } int get(int u){ int res = 0; while(u <= n){ res = max(res, bit[u]); u += (u & -u); } return res; } vector <tuple<int, int, int>> Megumi[mn]; void solve(){ cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; pre[i] = i - 1; while(pre[i] > 0 && a[i] >= a[pre[i]]) pre[i] = pre[pre[i]]; } for(int i = 1; i <= m; i++){ int l, r, k; cin >> l >> r >> k; Megumi[r].push_back({l, i, k}); } for(int i = 1; i <= n; i++){ if(pre[i] > 0) add(pre[i], a[pre[i]] + a[i]); for(auto [l, id, k] : Megumi[i]){ int val = get(l); ans[id] = (val <= k ? 1 : 0); } } for(int i = 1; i <= m; i++) cout << ans[i] << '\n'; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); if(fopen("HILO1.INP", "r")){ freopen("HILO1.INP", "r", stdin); freopen("HILO1.OUT", "w", stdout); } int t = 1; // cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:59:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |         freopen("HILO1.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:60:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |         freopen("HILO1.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...