[Codeforces] [604A] Uncowed Forces

Problem Description

Loading...

Problem Analysis

Mind the data types
to prevent precision loss

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
double max(double a,double b) {
    return a>b?a:b;
}
int main() {
    int m[5];
    while(scanf("%d",&m[0])!=EOF) {
        int s[]= {500,1000,1500,2000,2500};
        for(int i=1; i<5; i++)
            scanf("%d",&m[i]);
        int w[5];
        for(int i=0; i<5; i++)
            scanf("%d",&w[i]);
        int h1,h2;
        scanf("%d %d",&h1,&h2);
        double sum=0;
        for(int i=0; i<5; i++) {
            sum+=max(0.3*s[i],(1-m[i]/250.0)*s[i]-50*w[i]);
        }
        printf("%.lf\n",sum+100*h1-50*h2);
    }
    return 0;
}

Loading...