QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#600173#9427. Collect the Coinsucup-team918WA 10ms6080kbC++142.1kb2024-09-29 15:12:142024-09-29 15:12:17

Judging History

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

  • [2024-11-06 15:56:27]
  • hack成功,自动添加数据
  • (/hack/1139)
  • [2024-09-29 15:12:17]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:6080kb
  • [2024-09-29 15:12:14]
  • 提交

answer

bool M1;
#define look_memory cerr<<abs(&M2-&M1)/1024.0/1024<<" MB\n"
#define look_time cerr<<(clock()-Time)*1.0/CLOCKS_PER_SEC<<'\n'
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <cstring>
#include <array>
#include <algorithm>
#include <queue>
#include <vector>
#include <bitset>
#include <ctime>
#include <cstdlib>
#include <random>
#include <set>
#include <ctime>
#include <map>
#include <stack>
#include <unordered_map>
#include <assert.h>
#define i128 __int128
#define ll long long
#define uint unsigned
#define ull unsigned long long
#define fo(a,b,c) for(ll a=b;a<=c;++a)
#define re(a,b,c) for(ll a=b;a>=c;--a)
#define pii pair<ll,ll>
#define pdd pair<db,db>
#define fi first
#define pb push_back
#define se second
#define ite set<pii> ::iterator
#define vite vector<ll> ::iterator
using namespace std;
const ll mod=998244353;
inline ll gi()
{
	ll x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9')
	{
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9')
	{
		x = (x<<1) + (x<<3) + (ch^48);
		ch = getchar();
	}
	return x * f;
}
ll _=1;
const ll inf=2e17+5,iinf=1e9;
const ll N=1000005;
ll t[N],c[N],n;
map<ll,ll> mp;
ll ck(ll v)
{
	ll z=0,rem=0;
	fo(i,2,n)
	{
		ll delt=t[i]-t[i-1];
		if(delt*v>=abs(c[i]-c[i-1]))
		{
			delt=t[i]-t[z];
			if((delt*v>=abs(c[i]-c[z])||z==0)&&rem==0) rem=i-1;
			continue;
		}
		ll ok=0;
		while(z!=i)
		{
			if(z==0)
			{
				ok=1;
				break;
			}
			else
			{
				delt=t[i]-t[z];
				if(delt*v>=abs(c[i]-c[z]))
				{
					ok=1;
					break;
				}
			}
			z++;
			z=max(z,rem);
		}
		if(ok)
		{
			z=i-1;
			rem=0;
		}
		else return 0;
	}
	return 1;
}
void sol()
{
	n=gi();
	fo(i,1,n)
	{
		t[i]=gi();
		c[i]=gi();
	}
	ll ans=-1;
	ll l=0,r=1000000000;
	while(l<=r)
	{
		ll mid=(l+r)/2;
		if(ck(mid))
		{
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	cout<<ans;
}
bool M2;
int main()
{
	int Time=clock();
	look_memory;
	_=gi();
	while(_--)
	{
		sol();
		printf("\n");
	}
	look_time;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5876kb

input:

3
5
1 1
3 7
3 4
4 3
5 10
1
10 100
3
10 100
10 1000
10 10000

output:

2
0
-1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 10ms
memory: 6080kb

input:

1135
2
6 5
8 8
8
2 9
2 10
4 4
5 3
6 2
6 8
8 2
8 7
1
9 1
6
4 6
6 1
6 2
9 10
10 1
10 7
5
1 6
2 5
6 7
8 6
10 3
8
1 10
5 4
5 7
6 1
6 6
8 4
9 1
9 4
8
1 1
1 3
2 9
3 3
5 9
6 10
9 7
10 7
3
5 8
6 6
10 6
7
2 9
4 7
5 10
6 3
6 7
8 9
10 1
6
1 4
2 8
5 9
7 10
9 1
10 5
9
2 7
4 5
5 9
6 10
7 4
9 4
9 9
10 3
10 7
1
3 1...

output:

0
3
0
3
1
3
6
0
3
2
2
0
2
5
0
1
5
1
2
0
0
0
1
4
2
0
2
1
3
0
3
2
3
2
5
3
1
1
0
1
1
1
0
2
0
1
0
1
0
2
1
0
2
3
4
4
1
1
1
0
1
3
0
1
4
4
2
0
0
2
2
6
4
2
1
0
0
1
0
2
1
2
0
1
1
3
0
0
1
2
0
3
0
2
2
2
1
0
0
0
5
1
2
0
6
1
1
1
2
2
2
0
3
1
4
3
6
0
8
1
1
3
0
2
2
4
1
1
0
0
0
7
2
2
1
0
0
3
1
2
1
1
2
3
3
0
3
3
3
5
...

result:

wrong answer 67th lines differ - expected: '3', found: '2'