Submission #29046

# Submission time Handle Problem Language Result Execution time Memory
29046 2017-07-18T07:29:33 Z aybala Dancing Elephants (IOI11_elephants) C++11
0 / 100
99 ms 17644 KB
#include "elephants.h"
#include<bits/stdc++.h>
#define fori(a,b,c) for(a=b; a<c; a++)
#define ford(a,b,c) for(a=b; a>=c; a--)
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
int n;

int cam;

int a[2];

int Ll;
void init(int N, int L, int X[])
{
	int i,j,k;
	int l = X[0];
	a[0]=X[0];
	a[1]=X[1];
	cam = 1;
	fori(i,1,N){
		if(X[i]-l>L){
			l=X[i];
			cam++;
		}
	}
	n=N;
	Ll=L;
}

int update(int i, int y)
{
	if(i==2){
		a[0]=a[1]=y;
		return cam;
	}
	
	if(i==1){
		if(abs(a[1]-y)>abs(a[0]-y)){
			a[1]=y;
		}
		else{
			a[0]=y;
		}
		int l = a[0];
		cam = 1;
		fori(i,1,n){
			if(a[i]-l>Ll){
				l=a[i];
				cam++;
			}
		}	
	}
	
	return cam;
}

Compilation message

elephants.cpp: In function 'void init(int, int, int*)':
elephants.cpp:19:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j,k;
        ^
elephants.cpp:19:10: warning: unused variable 'k' [-Wunused-variable]
  int i,j,k;
          ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 17644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 17644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 17644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 17644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 17644 KB Output isn't correct
2 Halted 0 ms 0 KB -