[Offer收割]编程练习赛12 register

Ended

Participants:1323

Verdict:Accepted
Score:100 / 100
Submitted:2017-04-02 12:28:57

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
int main() {
//  freopen("input.txt", "r", stdin);
    map<int, int> line;
    int N, C, Ci;
    scanf("%d", &N);
    int ans = 0;
    for (int i=0; i<N; i++){
        scanf("%d", &C);
        int x = 0;
        while (C--) {
            scanf("%d", &Ci);
            if (C == 0)
                break;
            x += Ci;
            if (line.find(x) == line.end())
                line[x] = 1;
            else
                line[x]++;
        }       
        if (!line.empty())
            for (map<int, int>::iterator it = line.begin(); it != line.end(); it++)
                if (it->second > ans)
                    ans = it->second;
    }
    printf("%d\n", N - ans);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX