제출 #1121277

#제출 시각아이디문제언어결과실행 시간메모리
1121277MansurtFountain (eJOI20_fountain)C++17
0 / 100
1540 ms4172 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 = d[r]; 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...