# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
466989 | mtxas | Fountain (eJOI20_fountain) | C++14 | 3 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define mfsadfp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mii map<int, int>
#define all(a) a.begin(), a.end()
#define _fre() freopen("input.txt", "r", stdin)
#define turbo() cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false)
#define sz(x) ((int)x.size())
#define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++)
#define _foreq(a, b, c) for(int (a) = (b); (a) <= (c); (a)++)
#define _forneq(a, b, c) for(int (a) = (b); (a) >= (c); (a)--)
#define _forn(a, b, c) for(int (a) = (b); (a) > (c); (a)--)
using namespace std;
/***********************************************************************************
STRUCTS
************************************************************************************/
/***********************************************************************************
VARIABLES
************************************************************************************/
const int maxn = 2001;
int n, q;
int c[maxn], d[maxn], r[maxn], v[maxn];
/***********************************************************************************
FUNCTIONS
************************************************************************************/
int query(int R, int V){
int lastId = 0;
_foreq(j, R, n){
while(d[j] <= d[lastId]){
j++;
if(j == n+1) return 0;
} // d[j] > d[lastId]
V-= c[j];
if(V <= 0) return j;
lastId = j;
}
return 0;
}
/***********************************************************************************
MAIN
************************************************************************************/
int main(){
// _fre();
turbo();
cin>>n>>q;
_foreq(i, 1, n) cin>>d[i]>>c[i];
_for(i, 0, q) cin>>r[i]>>v[i];
_for(g, 0, q){
cout<<query(r[g], v[g])<<'\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |