Submission #166659

# Submission time Handle Problem Language Result Execution time Memory
166659 2019-12-03T12:03:51 Z ArKCa San (COCI17_san) C++17
48 / 120
1000 ms 376 KB
#include<bits/stdc++.h>
#define ll long long 
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define N 45
using namespace std;

ll  g[N],h[N],n,k;
vector<ll>v[N];

ll solve(ll x,ll mani){
	// printf("%d %d\n",x,mani);
	ll ans=0;
	if(mani+g[x]>=k){
		ans=1;
	}
	for(ll i=0;i<v[x].size();i++){
		ans+=solve(v[x][i],mani+g[x]);
	}
	return ans;
}

int main(){
	// freopen("a.gir","r",stdin);
 //    freopen("a.cik","w",stdout);
    scanf("%lld %lld",&n,&k);
    for(ll i=0;i<n;i++){
    	scanf("%lld %lld",&h[i],&g[i]);
    }
    for(ll i=0;i<n;i++){
    	for(ll j=i+1;j<n;j++){
    		if(h[j]>=h[i]){
    			v[i].pb(j);
    		}
    	}
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
    	ans+=solve(i,0);
    }
    printf("%lld\n",ans );
}

Compilation message

san.cpp: In function 'long long int solve(long long int, long long int)':
san.cpp:18:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ll i=0;i<v[x].size();i++){
             ~^~~~~~~~~~~~
san.cpp: In function 'int main()':
san.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
san.cpp:29:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%lld %lld",&h[i],&g[i]);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 128 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 252 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -