Safety index predicted at the end of the period (202012-1) (100 points)

Problem description

Question No.:202012-1
Test title:Safety index of end of period forecast
time limit:1.0s
Memory limit:512.0MB
Problem Description:

Topic background

The end of the term is coming. Xiaocai found his good friend Dunton, hoping to predict whether he will fail this semester.

Title Description

First of all, Dunton selected such as "classroom performance", "self-study duration", "homework score", "community activity participation", etc   n   This index is used as the basis for prediction.
Then, according to his secret observation of small dishes on weekdays, Dunton scores each index with a percentage system, that is, the third grade of small dishes   Score of index i (1 ≤ i ≤ n)   scorei   It's a   [0,100]   Integer in range.
Since the importance of each indicator is different, use one   [−10,10]   Integer in range   wi   To represent the second   The importance of i (1 ≤ i ≤ n) index.

Finally, the safety index of Xiaocai students at the end of the term   y   It is defined as follows:
y=ReLU(∑i=1nscorei⋅wi)

among   ReLU(x)=max(0,x)   Is a common activation function.
Because of the use of   ReLU   Function, the safety index must be a non negative value.
If the safety index is too low (or even zero), it means that the students of Xiaocai are likely to fail this semester

The importance of each indicator is known   wi   And corresponding scores   scorei, let's calculate the safety index of Xiaocai students at the end of the term.

Input format

Read in data from standard input.

The first line of input contains a positive integer   n. Guarantee   2≤n≤105.

Next enter   n   Line, where   The I (1 ≤ I ≤ n) line contains two integers separated by spaces   wi   and   scorei, respectively   i   The importance of the item and the score of the students in the item.

Output format

Output to standard output.

Output a nonnegative integer   y. Indicates the safety index of the end of the period.

Example 1 input

6
2 60
10 100
0 70
0 0
-10 50
10 60

Data

Sample 1 output

1220

Data

Example 1 explanation

y=ReLU(1220)=1220

Example 2 Input

2
-10 100
-1 15

Data

Example 2 output

0

Data

Example 2 explanation

y=ReLU(−1015)=0

//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<list>
#include<set>
#include<iomanip>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cassert>
#include<sstream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
typedef long long  ll;
#define ls (p<<1)
#define rs (p<<1|1)
#define mid (l+r)/2
#define over(i,s,t) for(register long long i=s;i<=t;++i)
#define lver(i,t,s) for(register long long i=t;i>=s;--i)
const int MAXN = 305;
const int INF = 0x3f3f3f3f;
const int N=5e4+7;
const int maxn=1e5+5;
const double EPS=1e-10;
const double Pi=3.1415926535897;
//inline double max(double a,double b){
//    return a>b?a:b;
//}
//inline double min(double a,double b){
//    return a<b?a:b;
//}
 
int xd[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int yd[8] = {1, 0, -1, 0, -1, 1, -1, 1};
 
//void Fire(){
//    queue<node> p;
//    p.push({fx,fy,0});
//    memset(fire, -1, sizeof(fire));
//    fire[fx][fy]=0;
//    while(!p.empty()){
//        node temp=p.front();
//        p.pop();
//        for(int i=0;i<8;i++){
//            int x=temp.x+xd[i];
//            int y=temp.y+yd[i];
//            if(x<0||x>=n||y<0||y>=m||fire[x][y]!=-1){
//                continue;
//            }
//            fire[x][y]=temp.val+1;
//            p.push({x,y,temp.val+1});
//        }
//    }
//}
//int bfs(){
//    queue<node> p;
//    memset(vis, 0, sizeof(vis));
//    p.push({sx,sy,0});
//    while (!p.empty()) {
//        node temp=p.front();
//        vis[temp.x][temp.y]=1;
//        p.pop();
//        for(int i=0;i<4;i++){
//            int x=temp.x+xd[i];
//            int y=temp.y+yd[i];
//            if(x<0||x>=n||y<0||y>=m)  continue;
//            if(x==ex&&y==ey&&temp.val+1<=fire[x][y]) return temp.val+1;
//            if(vis[x][y]||temp.val+1>=fire[x][y]||a[x][y]=='#') continue;
//            p.push({x,y,temp.val+1});
//        }
//    }
//    return -1;
//}
int n;
int sum;
int a,b;
int main(){
    cin>>n;
    while (n--) {
        cin>>a>>b;
        sum+=(a*b);
    }
    if(sum<0) cout<<0;
    else cout<<sum;
}

Keywords: Algorithm codeforce AcWing

Added by keystroke on Fri, 19 Nov 2021 09:12:51 +0200