流量监测
This commit is contained in:
parent
3ede0ad170
commit
7de6349786
BIN
4080_howmanycar/doc/流量监测.pdf
Normal file
BIN
4080_howmanycar/doc/流量监测.pdf
Normal file
Binary file not shown.
77
4080_howmanycar/howmanycar.cpp
Normal file
77
4080_howmanycar/howmanycar.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int n, a[1001][3], ans[2] = { 0 },kaishi=1;
|
||||||
|
bool pan = 0;
|
||||||
|
string s;
|
||||||
|
cin >> n;
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
int yi, er;
|
||||||
|
cin >> s >> a[i][1] >> a[i][2];
|
||||||
|
yi = a[i][1], er = a[i][2];
|
||||||
|
if (s == "on") {
|
||||||
|
a[i][0] = 1;
|
||||||
|
ans[0] += a[i][1];
|
||||||
|
ans[1] += a[i][2];
|
||||||
|
}
|
||||||
|
if (s == "none") {
|
||||||
|
a[i][0] = 2;
|
||||||
|
kaishi=i;
|
||||||
|
if (pan == 1) {
|
||||||
|
if (yi > ans[0]) {
|
||||||
|
ans[0] = yi;
|
||||||
|
}
|
||||||
|
if (er < ans[1]) {
|
||||||
|
ans[1] = er;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ans[0] = a[i][1];
|
||||||
|
ans[1] = a[i][2];
|
||||||
|
}
|
||||||
|
pan = 1;
|
||||||
|
}
|
||||||
|
if (s == "off") {
|
||||||
|
a[i][0] = 3;
|
||||||
|
ans[0] -= a[i][2];
|
||||||
|
ans[1] -= a[i][1];
|
||||||
|
if(ans[0]<0){
|
||||||
|
ans[0]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//cout << ans[0] << " " << ans[1] << endl;
|
||||||
|
}
|
||||||
|
int ans1[2];
|
||||||
|
pan=0;
|
||||||
|
for(int i=kaishi;i>=1;i--){
|
||||||
|
int yi = a[i][1], er = a[i][2];
|
||||||
|
if (a[i][0]==3) {
|
||||||
|
ans1[0] += a[i][1];
|
||||||
|
ans1[1] += a[i][2];
|
||||||
|
}
|
||||||
|
if (a[i][0] == 2) {
|
||||||
|
kaishi=i;
|
||||||
|
if (pan == 1) {
|
||||||
|
if (yi > ans1[0]) {
|
||||||
|
ans1[0] = yi;
|
||||||
|
}
|
||||||
|
if (er < ans1[1]) {
|
||||||
|
ans1[1] = er;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ans1[0] = a[i][1];
|
||||||
|
ans1[1] = a[i][2];
|
||||||
|
}
|
||||||
|
pan = 1;
|
||||||
|
}
|
||||||
|
if (a[i][0]==1) {
|
||||||
|
ans1[0] -= a[i][2];
|
||||||
|
ans1[1] -= a[i][1];
|
||||||
|
if(ans1[0]<0){
|
||||||
|
ans1[0]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << ans1[0] << " " << ans1[1]<<endl;
|
||||||
|
cout << ans[0] << " " << ans[1];
|
||||||
|
}
|
BIN
4080_howmanycar/howmanycar.exe
Normal file
BIN
4080_howmanycar/howmanycar.exe
Normal file
Binary file not shown.
4
4080_howmanycar/test/In1 (18).txt
Normal file
4
4080_howmanycar/test/In1 (18).txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
3
|
||||||
|
on 3 7
|
||||||
|
none 5 5
|
||||||
|
off 3 7
|
10
4080_howmanycar/test/In2 (10).txt
Normal file
10
4080_howmanycar/test/In2 (10).txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
9
|
||||||
|
on 0 0
|
||||||
|
off 1 2
|
||||||
|
on 0 0
|
||||||
|
off 2 3
|
||||||
|
on 2 2
|
||||||
|
on 1 3
|
||||||
|
none 479 540
|
||||||
|
on 1 1
|
||||||
|
on 0 2
|
5
4080_howmanycar/test/in.txt
Normal file
5
4080_howmanycar/test/in.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
4
|
||||||
|
on 1 1
|
||||||
|
none 10 14
|
||||||
|
none 11 15
|
||||||
|
off 2 3
|
21
4080_howmanycar/test/out.txt
Normal file
21
4080_howmanycar/test/out.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
## z:\Chao\src\4080_howmanycar\test\in.txt
|
||||||
|
2020/04/06 ÖÜÒ» 11:14:31.01
|
||||||
|
10 13
|
||||||
|
8 12
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 230 ms with return value 0
|
||||||
|
|
||||||
|
## z:\Chao\src\4080_howmanycar\test\In1 (18).txt
|
||||||
|
2020/04/06 ÖÜÒ» 11:14:31.01
|
||||||
|
0 2
|
||||||
|
0 2
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 90 ms with return value 0
|
||||||
|
|
||||||
|
## z:\Chao\src\4080_howmanycar\test\In2 (10).txt
|
||||||
|
2020/04/06 ÖÜÒ» 11:14:31.01
|
||||||
|
477 542
|
||||||
|
480 543
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 80 ms with return value 0
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
## z:\Chao\src\Template\test\in.txt
|
|
||||||
2020/03/14 ÖÜÁù 11:41:28.68
|
|
||||||
Hello Easy C++ project!
|
|
||||||
|
|
||||||
-----------------------------------------------
|
|
||||||
Process exited after 200 ms with return value 0
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user