标签:codeforces
题意:
编号为1、2、3的同学分成一组 问 最多形成多少组 并输出方案
思路:
模拟3个栈暴力
代码:
#include<cstdio> #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<map> #include<set> #include<vector> #include<queue> #include<cstdlib> #include<ctime> #include<cmath> using namespace std; typedef long long LL; #define N 5010 int man[4][N], d[4]; int n; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { int ff; scanf("%d", &ff); man[ff][d[ff]] = i; d[ff]++; } int ans = min(d[1], min(d[2], d[3])); printf("%d\n", ans); for (int i = 0; i < ans; i++) printf("%d %d %d\n", man[1][i], man[2][i], man[3][i]); return 0; }
标签:codeforces
原文地址:http://blog.csdn.net/houserabbit/article/details/41440739