답안 #844726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844726 2023-09-05T18:22:18 Z HaciyevAlik Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 3688 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//I Sawed the Demons
using ll = long long;
using ld = long double;
using ordered_set = tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>;
#define pb push_back
#define oo 1000000000000000000
#define ff first
#define ss second

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
   	int n,q; cin >> n >> q;
   	vector<int> d(n+1),c(n+1);
   	for(int i=1;i<=n;++i) {
   		cin >> d[i] >> c[i];
   	}
   	while(q--) {
   		int r,v; cin >> r >> v;
   		int dia=d[r],cur=v-c[r];
   		if(cur<=0) {
   			cout << r << "\n"; continue;
   		}
   		bool f=0;
   		for(int i=r+1;i<=n;++i) {
   			if(d[i]>dia) {
   				dia=d[i];
   				cur-=c[i];
   				if(cur<=0) {
   					f=1;
   					cout << i << "\n"; break;
   				}
   			}
   		}
   		if(!f) cout << "0\n";
   	}
    return 0;
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1556 ms 3688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Execution timed out 1556 ms 3688 KB Time limit exceeded
9 Halted 0 ms 0 KB -