제출 #1057550

#제출 시각아이디문제언어결과실행 시간메모리
1057550beaconmcGift Exchange (JOI24_ho_t4)C++14
8 / 100
58 ms7000 KiB
#include <bits/stdc++.h> typedef long long ll; #define FOR(i,x,y) for(ll i=x; i<y; i++) #define FORNEG(i,x,y) for(ll i=x; i>y; i--) using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin >> n; vector<ll> vals(n), req(n); FOR(i,0,n) cin >> vals[i]; FOR(i,0,n) cin >> req[i]; vector<bool> visited(n); vector<bool> ending(n); vector<bool> starting(n); ending[0] = 1; FORNEG(i, n-1, 0){ if (visited[i] == 0) starting[i] = 1; if (vals[i-1] >= req[i]) visited[i] = 1, visited[i-1] = 1; else ending[i] = 1; } vector<ll> pref(n); pref[0] = visited[0]; FOR(i,1,n) pref[i] = pref[i-1] + visited[i]; ll q; cin >> q; FOR(i,0,q){ ll a,b; cin >> a >> b; a--;b--; ll sus = pref[b] - pref[a] + visited[a]; if (sus == (b-a+1) && !ending[b] && !starting[a]) cout << "Yes" << "\n"; else cout << "No" << "\n"; } }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...