QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395519#4377. BackpackCMingTL 0ms0kbC++141013b2024-04-21 15:53:392024-04-21 15:53:39

Judging History

你现在查看的是最新测评结果

  • [2024-04-21 15:53:39]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-21 15:53:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N = 1024;
void solve()
{
    int n, m; cin >> n >> m;
    vector<int> v(n + 1), w(n + 1);
    for(int i = 1; i <= n; i++) cin >> v[i] >> w[i];
    
    vector<bitset<N> > f(N);
    f[0][0] = 1;

    for(int i = 1; i <= n; i++)
	{
		// cout << "i = " << i << "---------\n";
        for(int k = 0; k < N; k++)
		{
        	for(int j = m; j >= v[i]; j--)
                f[k] |= f[k ^ w[i]] << v[i];
			// cout << k << ":" << f[k] << "\n";
		}

	}


    for(int i = N - 1; i >= 0; i--)
        if(f[i][m])
        {
            cout << i << '\n';
            return;
        }

	cout << "1\n";
}

signed main()
{
	//freopen("D:\\VSC\\00\\in.txt","rt",stdin);
	//freopen("D:\\VSC\\00\\out.txt","wt",stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1;
	cin >> t;
	while (t--)
	{
		#ifdef BOOL
		if(solve()) cout << "YES\n";
		else cout << "NO\n";
		#else
		solve();
		#endif
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

10
1023 401
179 441
416 951
420 984
1013 984
683 914
407 984
96 523
374 190
974 190
739 441
518 523
194 984
415 523
149 441
235 984
809 441
469 441
436 919
437 919
7 919
818 984
962 190
37 919
371 523
417 914
431 914
213 190
340 441
254 919
223 951
123 190
339 951
322 441
218 441
284 919
533 190
187...

output:


result: