Submission #132955

#TimeUsernameProblemLanguageResultExecution timeMemory
132955zozderRace (IOI11_race)C++14
0 / 100
3 ms1144 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...