Skip to content

Instantly share code, notes, and snippets.

@MohamedTaha98
Created July 26, 2017 23:06
Show Gist options
  • Save MohamedTaha98/69f1e2aa07a94f60a9d74633c3e37c2e to your computer and use it in GitHub Desktop.
Save MohamedTaha98/69f1e2aa07a94f60a9d74633c3e37c2e to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
long long n, change25 = 0, change50 = 0, remainall = 0, remain25 = 0, remain50 = 0;
string a = "YES";
cin >> n;
long long ar[n];
for (int i = 0; i < n; i++)
{
cin >> ar[i];
if (ar[i] == 25)
change25++;
else if (ar[i] == 50)
change50++;
remainall = ar[i] - 25;
if (change50 != 0)
{
remain50 = remainall / 50;
remainall %= 50;
change50 -= remain50;
}
remain25 = remainall / 25;
remainall %= 25;
change25 -= remain25;
if (change25 < 0 || change50 < 0)
{
a = "NO";
break;
}
}
cout << a;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment