File tree 2 files changed +69
-0
lines changed
2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < bits/stdc++.h>
3
+ #define ll long long
4
+ using namespace std ;
5
+
6
+ int main () {
7
+ ll int t;
8
+ cin>>t;
9
+ while (t--){
10
+ ll int x, n;
11
+ cin >> n >> x;
12
+ ll int s[n], r[n], max;
13
+ for (ll int i=0 ; i<n; i++){
14
+ cin>>s[i]>>r[i];
15
+ }
16
+ if (n>=1 && s[0 ]<=x){
17
+ max=r[0 ];
18
+ }
19
+ else {
20
+ max=0 ;
21
+ }
22
+ for (ll int i=1 ; i<n; i++){
23
+ if (r[i]>max && s[i]<=x){
24
+ max=r[i];
25
+ }
26
+ }
27
+ cout<<max<<endl;
28
+ }
29
+ return 0 ;
30
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < algorithm>
3
+ #include < bits/stdc++.h>
4
+ #include < vector>
5
+
6
+ using namespace std ;
7
+
8
+ int main (){
9
+ int t;
10
+ cin >> t;
11
+ while (t--){
12
+ int n, d, h, u=0 ;
13
+ string ans = " NO" ;
14
+ cin>>n>>d>>h;
15
+ int A[n];
16
+ for (int i=0 ; i<n; i++){
17
+ cin >> A[i];
18
+ }
19
+ for (int j=0 ; j<n; j++){
20
+ if (A[j]>0 ){
21
+ u+=A[j];
22
+ }
23
+ else {
24
+ if (u<d){
25
+ u=0 ;
26
+ }
27
+ else {
28
+ u-=d;
29
+ }
30
+ }
31
+ if (u>h){
32
+ ans = " YES" ;
33
+ break ;
34
+ }
35
+ }
36
+ cout << ans << endl;
37
+ }
38
+ return 0 ;
39
+ }
You can’t perform that action at this time.
0 commit comments