流量监测

This commit is contained in:
James 2020-04-06 11:36:49 +08:00
parent 3ede0ad170
commit 7de6349786
13 changed files with 117 additions and 7 deletions

Binary file not shown.

View 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];
}

Binary file not shown.

View File

@ -0,0 +1,4 @@
3
on 3 7
none 5 5
off 3 7

View 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

View File

@ -0,0 +1,5 @@
4
on 1 1
none 10 14
none 11 15
off 2 3

View 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

View File

@ -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