Test instructions: Sort from small to large
Petition said the input has 25MB, but the memory limit is only 2MB,
I wrote it with sort, and I ~~~~~.
Learned the Count sort----
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <Set>9#include <queue>Ten#include <algorithm> One using namespacestd; A -typedefLong LongLL; - Const intINF = (1<< -)-1; the Const intMod=1000000007; - Const intmaxn=2000005; - - intA[MAXN]; + intN; - + intMain () { A while(SCANF ("%d", &n)! = EOF &&N) { at for(inti =1; i<=n;i++) scanf ("%d",&a[i]); -Sort (A +1, a+n+1); - for(intI=1; i<n;i++) printf ("%d", A[i]); -printf"%d\n", A[n]); - } - return 0; in}
View Code
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <Set>9#include <queue>Ten#include <algorithm> One using namespacestd; A -typedefLong LongLL; - Const intINF = (1<< -)-1; the Const intMod=1000000007; - Const intmaxn=1000005; - - intc[ the]; + intN; - + intMain () { A while(SCANF ("%d", &n)! = EOF &&N) { atMemset (c,0,sizeof(c)); - for(inti =0; I < n;i++){ - intx; -scanf"%d",&x); -c[x]++; - } in - intFirst =1; to for(inti =0; i<= -; i++){ + for(intj =0; J < c[i];j++){ - if(!first) printf (" "); theFirst =0; *printf"%d", i); $ }Panax Notoginseng } -printf"\ n"); the } + return 0; A}
View Code
UVa 11462 Age Sort