Submission #666447

#TimeUsernameProblemLanguageResultExecution timeMemory
666447TrumlingRobots (IOI13_robots)C++14
Compilation error
0 ms0 KiB
#include "robots.h"
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
 

int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) 
{
sort(x,x+a,greater<ll>());
sort(w,w+t,greater<ll>());

if(x[0]<=w[0])
return -1;


ll idx=0;
ll arr[a+1];
for(int i=0;i<a;i++)
{
	while(idx<t && w[idx]>=x[i])
	{
		idx++;
	}
	arr[i]=idx;
}
arr[a]=t;
ll pre=arr[0],rest=0,count=1;
ll time=0;
for(int i=1;i<=a;i++)
{
	if(arr[i]==pre){
	count++;
	continue;
	}
	ll now=(arr[i]-pre)/count;
	ll rem=(arr[i]-pre)%count;
	if(rem)
		now++;
	rem=count-rem;
	
	if(time==0)
	{
		count=1;
		time=now;
		rest+=rem;
		pre=arr[i];
		continue;
	}


	if(now<=time)
	{
		count=1;
		rest+=rem;
		pre=arr[i];
		continue;
	}


		ll toys=(arr[i]-pre)-count*(time-1);
		toys-=count+rest;

		if(toys<=0)
		{
			count=1;
			rest=-toys;
			pre=arr[i];
			continue;
		}

		now=toys/(i+1);
		if(toys%(i+1))
		now++;

		time=now;
		rest=i+1-toys%(i+1);
		pre=arr[i];
		count=1;
}
return time;
}


#include <stdio.h>
#include <stdlib.h>
#include "robots.h"

#define fail(s, x...) do { \
		fprintf(stderr, s "\n", ## x); \
		exit(1); \
	} while(0)

#define MAX_A 50000
#define MAX_B 50000
#define MAX_T 500000

static int X[MAX_A];
static int Y[MAX_B];
static int W[MAX_T];
static int S[MAX_T];

int main() {
    int A, B, T, i;
	int res;
	cin>>A>>B>>T;
	for(int j=0;j<A;j++)
	cin>>X[j];

	for(int j=0;j<B;j++)
	cin>>Y[j];

	for(int j=0;j<T;j++)
	cin>>W[j]>>S[j];
	int answer = putaway(A, B, T, X, Y, W, S);
	printf("%d\n", answer);

	return 0;
}

Compilation message (stderr)

robots.cpp: In function 'int main()':
robots.cpp:108:18: warning: unused variable 'i' [-Wunused-variable]
  108 |     int A, B, T, i;
      |                  ^
robots.cpp:109:6: warning: unused variable 'res' [-Wunused-variable]
  109 |  int res;
      |      ^~~
/usr/bin/ld: /tmp/ccYuR6A5.o: in function `main':
robots.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccUleXR3.o:grader.c:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status