Submission #132966

# Submission time Handle Problem Language Result Execution time Memory
132966 2019-07-20T03:03:27 Z zozder Race (IOI11_race) C++14
0 / 100
3 ms 1144 KB
#include "race.h"
#include <iostream>
#define maxn 200001

using namespace std;

int sum[maxn];
int ans=-1;

int best_path(int n, int K, int H[][2], int L[])
{
	for(int i=0;i<maxn;i++)sum[i]=0;
	for(int i=0;i<n-1;i++)
	{
		sum[i]+=L[i];
		sum[i+1]+=sum[i];
	}
	for(int i=0;i<n-1;i++)cout<<L[i]<<" ";cout<<endl;
	for(int i=0;i<n-1;i++)cout<<sum[i]<<" ";cout<<endl;
	for(int i=0;i<n-1;i++)
	for(int j=i;j<n-1;j++)
	{
		if(i==0)
		{
			if(sum[j]==K&&(j-i+1<ans||ans==-1))ans=j-i+1;
		}
		else if(sum[j]-sum[i-1]==K&&(j-i+1<ans||ans==-1))ans=j-i+1;
	}
	
	return ans;
}

Compilation message

race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:18:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i=0;i<n-1;i++)cout<<L[i]<<" ";cout<<endl;
  ^~~
race.cpp:18:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i=0;i<n-1;i++)cout<<L[i]<<" ";cout<<endl;
                                        ^~~~
race.cpp:19:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i=0;i<n-1;i++)cout<<sum[i]<<" ";cout<<endl;
  ^~~
race.cpp:19:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i=0;i<n-1;i++)cout<<sum[i]<<" ";cout<<endl;
                                          ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -