只有聰明人會對
智障不會對
#include <iostream>
#include <algorithm>
using namespace std;
/*run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int n;
while(cin>>n)
{
int t[5];
int f[9];
string ans="yes";
for(int i=1;i<5;i++)cin>>t[i];
for(int i=1;i<9;i++){
cin>>f[i];
if(i==1||ans="no")continue;
int x=f[i-1],y=f[i];
if(x>y) swap(x,y);
int sum=0;
for(int j=1;j<=(y-x);j++)sum+=t[x+j-1];
if(sum>n)ans="no";
}cout<<ans<<endl;
}