Submission #27045

# Submission time Handle Problem Language Result Execution time Memory
27045 2017-07-09T06:11:04 Z RayaBurong25_1 Bulldozer (JOI17_bulldozer) C++14
0 / 100
58 ms 360 KB
#include <stdio.h>
#include <vector>
#include <map>
#include <math.h>
double X[2005], Y[2005];
long long V[2005];
std::map<double, long long> M;
double dist(int i, int j)
{
	return sqrt((X[i]-X[j])*(X[i]-X[j]) + (Y[i]-Y[j])*(Y[i]-Y[j]));
}
long long min(long long a, long long b)
{
	return (a < b)?a:b;
}
long long max(long long a, long long b)
{
	return (a > b)?a:b;
}
int main()
{
	// freopen("test.in", "r", stdin);
	// freopen("test.out", "w", stdout);
	int N;
	scanf("%d", &N);
	int i, j, k;
	for (i = 0; i < N; i++)
		scanf("%lf %lf %d", &X[i], &Y[i], &V[i]);
	double a;
	std::map<double, long long>::iterator it;
	long long sum, summin, ans = 0;
	for (i = 0; i < N; i++)
	{
		for (j = i + 1; j < N; j++)
		{
			M.clear();
			a = acos((Y[j] - Y[i])/dist(i, j));
			for (k = 0; k < N; k++)
				M[-sin(a)*X[k]-cos(a)*Y[k]] += V[k];
			sum = 0;
			summin = 0;
			for (it = M.begin(); it != M.end(); it++)
			{
				sum += it->second;
				summin = min(summin, sum);
				ans = max(ans, sum - summin);
			}
		}
	}
	printf("%d", ans);
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:28:42: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   scanf("%lf %lf %d", &X[i], &Y[i], &V[i]);
                                     ~~~~~^
bulldozer.cpp:50:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  printf("%d", ans);
                  ^
bulldozer.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
bulldozer.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lf %lf %d", &X[i], &Y[i], &V[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 360 KB Output isn't correct
2 Halted 0 ms 0 KB -