diff --git a/Candies/Solution.cpp b/Candies/Solution.cpp index 1adf62b..068bb9c 100644 --- a/Candies/Solution.cpp +++ b/Candies/Solution.cpp @@ -2,24 +2,24 @@ #include using namespace std; -int GetRequiredCandies(vector Students) { - int N = Students.size(); - int TotalCandies = 0; +long long GetRequiredCandies(vector Students) { + long long N = Students.size(); + long long TotalCandies = 0; - vector Left = vector(N, 1); - vector Right = vector(N, 1); + vector Left = vector(N, 1); + vector Right = vector(N, 1); - for (int i = N - 2; i >= 0; i--) { + for (long long i = N - 2; i >= 0; i--) { if (Students[i + 1] < Students[i]) Right[i] = 1 + Right[i + 1]; } - for (int i = 1; i < N; i++) { + for (long long i = 1; i < N; i++) { if (Students[i - 1] < Students[i]) Left[i] = 1 + Left[i - 1]; } - for (int i = 0; i < N; i++) { + for (long long i = 0; i < N; i++) { TotalCandies += max(Right[i], Left[i]); } @@ -27,12 +27,12 @@ int GetRequiredCandies(vector Students) { } int main() { - int N, Score; + long long N, Score; cin >> N; - vector Students; + vector Students; - for (int i = 0; i < N; i++) { + for (long long i = 0; i < N; i++) { cin >> Score; Students.push_back(Score); } @@ -40,4 +40,4 @@ int main() { cout << GetRequiredCandies(Students) << endl; return 0; -} \ No newline at end of file +}