Skip to content

Instantly share code, notes, and snippets.

@KT-Yeh
Created February 16, 2014 16:41
Show Gist options
  • Save KT-Yeh/9036960 to your computer and use it in GitHub Desktop.
Save KT-Yeh/9036960 to your computer and use it in GitHub Desktop.
#include <cstdio>
using namespace std;
int main()
{
int t,n;
int p[30];
int diff[30];
while (scanf("%d%d" ,&t,&n) != EOF){
for (int i=0; i<n; i++) scanf("%d",&p[i]);
diff[0] = p[0];
for (int i=1; i<n; i++) diff[i] = p[i]-p[i-1];
printf("1");
for (int i=1; i<n; i++){
for (int Count = 1, j = i; j >= 0; --j, ++Count)
if (diff[j] > 0){
diff[j]--;
printf(" %d",Count);
break;
}
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment