이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define MAX 5e4 + 1
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 0x3F3F3F3F3F3F3F3FLL
#define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sec second
#define fi first
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main()
{
OPT
int n, q;
cin >> n >> q;
vector<int> c(n+1), d(n+1);
for(int i = 1; i<=n; i++)
{
cin >> d[i] >> c[i];
}
while(q--)
{
int r, v, ans = 0;
cin >> r >> v;
int temp = d[r];
v-=c[r];
ans = r;
if(v > 0)
{
for(int i = r+1; i<=n; i++)
{
if(d[i] > temp && v>0)
{
temp = d[i];
v -= c[i];
ans = i;
}
}
}
if(v>0)ans = 0;
cerr << "ans : ";
cout << ans << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |