답안 #769891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
769891 2023-06-30T12:36:13 Z TimDee Fountain (eJOI20_fountain) C++17
30 / 100
1500 ms 2256 KB
//  Esti <3

//\
     šťastia pre nás :)
//   you're already the best
//             _
//   ^ ^      //
// >(O_O)<___//
//   \ __ __  \
//    \\ \\ \\\\
 
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3","unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
 
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")

using ll = long long;
#define int long long
#define forn(i,n) for(int i=0; i<(n); ++i)
#define pb push_back
#define pi pair<int,int>
#define f first
#define s second 
#define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e18;
const int mod = 1e9+7;//998244353;
 
// \
\
:smiling_face_with_3_hearts: :smiling_face_with_3_hearts:  :smiling_face_with_3_hearts:  
 
//vidime sa veľmi skoro, moje slnko

void solve() {

	int n, q; cin>>n>>q;
	vector<pi> a(n);
	forn(i,n) cin>>a[i].f>>a[i].s;
	forn(i,q) {
		int r,v; cin>>r>>v;
		int last=0;
		for (int j=r-1; j<n; ++j) {
			//cout<<"? "<<a[i].f<<' '<<last<<'\n';
			if (a[j].f > last) {
				//cout<<"! "<<i<<' '<<v<<'\n';
				v-=a[j].s;
				last=a[j].f;
				if (v<=0) {
					cout<<j+1<<'\n';
					break;
				}
			}
		}
		if (v>0) cout<<"0\n";
	}

}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t=1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Compilation message

fountain.cpp:3:1: warning: multi-line comment [-Wcomment]
    3 | //\
      | ^
fountain.cpp:9:1: warning: multi-line comment [-Wcomment]
    9 | //   \ __ __  \
      | ^
fountain.cpp:36:1: warning: multi-line comment [-Wcomment]
   36 | // \
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1569 ms 2256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Execution timed out 1569 ms 2256 KB Time limit exceeded
9 Halted 0 ms 0 KB -