제출 #1123912

#제출 시각아이디문제언어결과실행 시간메모리
1123912MansurtFountain (eJOI20_fountain)C++17
30 / 100
1593 ms2296 KiB
#include <bits/stdc++.h> #define ll long long const ll N = 2*1e5+5; const ll mod = 1e9 + 7; using namespace std; ll d[N], c[N]; ll mul(ll a, ll b) { return (a % mod * b % mod) % mod; } ll bpow(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = mul(res, a); a = mul(a, a); b >>= 1; } return res; } int main() { cin.tie(nullptr)->sync_with_stdio(false); ll n,q; cin >> n >> q; for (int i = 1; i <= n; i++) { cin >> d[i] >> c[i]; } ll r,v; while(q--) { cin >> r >> v; ll prev = -12; bool fnd = false; for (int i = r; i <= n; i++) { if (d[i] <= prev) continue; v -= c[i]; if (v <= 0) { fnd = true; cout << i << '\n'; break; } prev = d[i]; } if (!fnd) { cout << 0 << '\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...