Submission #82561

# Submission time Handle Problem Language Result Execution time Memory
82561 2018-10-31T12:55:54 Z thiago4532 San (COCI17_san) C++17
0 / 120
351 ms 636 KB
#include <bits/stdc++.h>

using namespace std;
const int maxn = 40;
int h[maxn], c[maxn];
int n, k;

int main(){
	//ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;

	for(int i=1;i<=n;i++)
		cin >> h[i] >> c[i];

	int ans=0;
	for(int i=1;i<(1<<n);i++){
		vector<int> mark;

		int num=0;
		for(int j=1;j<=n;j++)
			if(i&(1<<(j-1))) mark.push_back(j), num += c[j];

		// cout << "{";
		// for(int i=0;i<mark.size();i++)
		// 	cout << mark[i] << ",}"[i==mark.size()-1];
		// cout << "\n";

		bool possible = (num >= k);
		if(!possible) continue;
		for(int j=0;j<mark.size()-1;j++){
			if(h[mark[j+1]] < h[mark[j]]){
				possible = false;
				break;
			}
		}
		if(possible) ++ans;
	}
	cout << ans << "\n";
	return 0;
}

Compilation message

san.cpp: In function 'int main()':
san.cpp:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<mark.size()-1;j++){
               ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 351 ms 636 KB Output is correct
2 Incorrect 336 ms 636 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 636 KB Output isn't correct
2 Halted 0 ms 0 KB -