답안 #166657

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166657 2019-12-03T11:59:15 Z ArKCa San (COCI17_san) C++17
0 / 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;

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

int solve(int x,int mani){
	// printf("%d %d\n",x,mani);
	ll ans=0;
	if(mani+g[x]>=k){
		ans=1;
	}
	for(int 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("%d %d",&n,&k);
    for(int i=0;i<n;i++){
    	scanf("%d %d",&h[i],&g[i]);
    }
    for(int i=0;i<n;i++){
    	for(int j=i+1;j<n;j++){
    		if(h[j]>=h[i]){
    			v[i].pb(j);
    		}
    	}
    }
    ll ans=0;
    for(int i=0;i<n;i++){
    	ans+=solve(i,0);
    }
    printf("%lld\n",ans );
}

Compilation message

san.cpp: In function 'int solve(int, int)':
san.cpp:18:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v[x].size();i++){
              ~^~~~~~~~~~~~
san.cpp: In function 'int main()':
san.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~
san.cpp:30:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d %d",&h[i],&g[i]);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1039 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1037 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1072 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -