那么

P1459 [USACO2.1] 三值的排序 Sorting a Three-Valued Sequence

是的,而且只有123,这题关键不在数字上
by Sky、 @ 2016-04-18 17:22:45


```cpp #include <fstream> using namespace std; int main() { ifstream fin("sort3.in"); ofstream fout("sort3.out"); int count[4],a[4],t[1001],x,n,k=0; memset(count,0,sizeof(count)); memset(a,0,sizeof(a)); fin>>n; while (fin>>x) { count[x]++; t[++k]=x; } for (int i=1;i<=count[1]+count[2];i++){ if (t[i]==3) a[3]++; else if (t[i]==2&&i<=count[1]) a[1]++; else if (t[i]==1&&i>count[1]) a[2]++; } fout<<a[3]+(a[1]>a[2]?a[1]:a[2])<<endl; } //nocow usaco 标程 ```
by NicodeX @ 2016-04-19 13:45:22


|