Submission #132955

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

int sum[maxn];
int ans=9999999;

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<maxn;i++)
	{
		sum[i]+=L[i];
		sum[i+1]+=sum[i];
	}
	
	for(int i=0;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	{
		if(i==0)
		{
			if(sum[j]==K&&j-i+1<ans)ans=j-i+1;
		}
		else if(sum[j]-sum[i-1]==K&&j-i+1<ans)ans=j-i+1;
	}
	
	return ans;
}

Compilation message

race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:14:11: warning: iteration 200000 invokes undefined behavior [-Waggressive-loop-optimizations]
   sum[i+1]+=sum[i];
   ~~~~~~~~^~~~~~~~
race.cpp:11:15: note: within this loop
  for(int i=0;i<maxn;i++)
               ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Incorrect 3 ms 1144 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Incorrect 3 ms 1144 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Incorrect 3 ms 1144 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Incorrect 3 ms 1144 KB Output isn't correct
4 Halted 0 ms 0 KB -