제출 #1284176

#제출 시각아이디문제언어결과실행 시간메모리
1284176adscodingHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
47 / 100
3093 ms22080 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define FOR(i, a, b) for (int i = a, _b = b; i <= _b; ++i) #define FORD(i, a, b) for (int i = a, _b = b; i >= _b; --i) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int maxn = 1e6 + 3; int n, q, a[maxn]; struct Qr { int l, r, k; } qrs[maxn]; namespace sub12 { bool approve() { return 1ll * q * n <= int(5e7); } void solve() { FOR(t, 1, q) { int ma = -1e9; bool c = true; FOR(i, qrs[t].l, qrs[t].r) { if (ma > a[i] && a[i] + ma > qrs[t].k) { c = false; break; } ma = max(ma, a[i]); } cout << c << '\n'; } } } namespace sub3 { int pre[maxn]; bool approve() { int ma = 1e9; FOR(i, 1, n) ma = min(ma, a[i]); FOR(i, 1, q) if (ma <= qrs[i].k) return false; return true; } void solve() { FOR(i, 2, n) { pre[i] = pre[i - 1]; if (a[i] < a[i - 1]) ++pre[i]; } FOR(t, 1, q) { cout << (pre[qrs[t].r] - pre[qrs[t].l] == 0) << '\n'; } } } void solve() { cin >> n >> q; FOR(i, 1, n) cin >> a[i]; FOR(i, 1, q) cin >> qrs[i].l >> qrs[i].r >> qrs[i].k; if (sub3 :: approve()) sub3 :: solve(); else sub12 :: solve(); } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define TASK "TEST" if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); freopen(TASK".OUT", "w", stdout); } solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

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