-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path1268_CNEASY.cpp
80 lines (77 loc) · 2.43 KB
/
1268_CNEASY.cpp
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
71
72
73
74
75
76
77
78
79
80
/*
* 2012/11/28
TASK: CN Tower (Easy)
*/
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
//#define TASK_NUM 100
#define EXPR_LENGTH 100
#define CASE_LENGTH 5
#define SPEED 4320
float maxSpace(vector<float> vec)
{
float max = 0.0;
int compare = vec.size() - 1;
for(int i = 0; i<compare; i++)
{
if(max<(vec[i+1]-vec[i]))
max = vec[i+1]-vec[i];
}
if(max < (vec[0]-vec[compare]+360))
max = vec[0]-vec[compare]+360;
return max;
}
int main()
{
char case_number[CASE_LENGTH];
cin.getline (case_number,CASE_LENGTH); // Read the next number
int caseNumber;
sscanf (case_number,"%d", &caseNumber);
vector<float> output;
while (caseNumber>0)
{
//cout<<"caseNumber ="<<caseNumber<<endl;
char landmark_number[CASE_LENGTH];
cin.getline (landmark_number, CASE_LENGTH); // Read the next number
int landmarknumber;
sscanf (landmark_number,"%d", &landmarknumber);
if ((landmarknumber>=2)&&(landmarknumber<=1000))
{
//cout<<"landmarknumber ="<<landmarknumber<<endl;
vector<float> vec;
vector<float>::iterator finded;
while(landmarknumber)
{
char strinput[EXPR_LENGTH];
cin.getline(strinput, EXPR_LENGTH); // Read the next number
char landmark_name[EXPR_LENGTH];
float landmark_direction;
sscanf (strinput,"%s %f", landmark_name, &landmark_direction);
//cout<<"landmark_name ="<<landmark_name<<endl;
//cout<<"landmark_direction ="<<landmark_direction<<endl;
finded = find(vec.begin(), vec.end(), landmark_direction);
if(finded==vec.end())
vec.push_back(landmark_direction);
landmarknumber--;
}
sort (vec.begin(), vec.end());
float max = 0.0;
int compare = vec.size() - 1;
for(int i = 0; i<compare; i++)
{
if(max<(vec[i+1]-vec[i]))
max = vec[i+1]-vec[i];
}
if(max < (vec[0]-vec[compare]+360))
max = vec[0]-vec[compare]+360;
output.push_back(max/360*4320);
}
caseNumber--;
}
for(int i = 0; i<output.size(); i++)
cout<<(4320-int(output[i]))<<endl;
return 0;
}