-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
70 lines (52 loc) · 840 Bytes
/
A.cpp
File metadata and controls
70 lines (52 loc) · 840 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int max(int *v){
int maior = -999999;
int freq = 0;
for (int i = 0; i < 10; ++i)
{
if (v[i] > maior){
maior = v[i];
freq = i;
}
}
return freq;
}
int main(int argc, char const *argv[])
{
vector<int> v;
int vet[10000];
int a,b,x,y,aux,maior;
scanf("%d %d", &a, &b);
for (int i = 0; i < a; ++i)
{
v.push_back(1);
}
for (int i = 0; i < b; ++i)
{
scanf("%d %d", &x, &y);
for (int j = x; j <= y; ++j)
{
vet[v.at(j)]++;
}
maior = max(vet);
for (int i = x; i <= y; ++i)
{
if (v.at(i) + maior >= 9)
v.at(i) = (v.at(i) + maior)-9;
else
v.at(i) = v.at(i)+maior;
}
for (int i = 0; i < 10 ; ++i)
{
vet[i] = 0;
}
}
for (int i = 0; i < a; ++i)
{
printf("%d\n",v.at(i));
}
return 0;
}