QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#800661#9798. Safety FirstYo1oWA 1ms3788kbC++17734b2024-12-06 14:08:052024-12-06 14:08:06

Judging History

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

  • [2024-12-06 14:08:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3788kb
  • [2024-12-06 14:08:05]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;

const int N = 1e6 + 10;
const ll INF = 1e6 + 10;

bool cmp(string x,string y)
{
	return x.size() < y.size();
}

void solve()
{

	ll n,m;
	
	cin>>n>>m;
	
	string s[n + 10];
	
	for(int i = 1;i <= n;i++)
	{
		cin>>s[i];
	}
	
	//sort(s + 1,s + 1 + n,cmp);
	
	ll res = 0;
	
	for(int i = 1;i <= n;i++)
	{
		if(m >= s[i].size())
		{
			m -= s[i].size();
			res++;
		}
		else
		{
			break;
		}
	}
	
	cout<<res<<'\n';

	
}

int main()
{
	
	ios::sync_with_stdio(0);
	cin.tie(0);	

	int T = 1;
	
	cin>>T;
	
	while(T--)
	{
		solve();
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3788kb

input:

3
1 3
2 3
3 3

output:

1
3
3

result:

wrong answer 2nd numbers differ - expected: '4', found: '3'