답안 #169261

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169261 2019-12-19T11:30:38 Z Ruxandra985 Sure Bet (CEOI17_sure) C++14
0 / 100
2 ms 380 KB
#include <bits/stdc++.h>
using namespace std;
double a[100010] , b[100010];
int f[100010];
int main()
{
    FILE *fin = stdin;
    int n , i;
    double  sx , sy , sol , luat;
    fscanf (fin,"%d",&n);
    sx = sy = 0.0;
    for (i=1;i<=n;i++){
        fscanf (fin,"%lf%lf",&a[i],&b[i]);

        if (sx < sy || (sx == sy && a[i] > b[i])){
            f[i] = 1;
            sx+=a[i];
        }
        else {
            f[i] = 2;
            sy+=b[i];
        }
    }
    sol = min(sx , sy) - 1.0 * n;
    luat = n;
    for (i=1;i<=n;i++){

        if (f[i] == 1){
            if (sol < min(sx - a[i] , sy) - 1.0 * luat + 1.0){
                sol = min(sx - a[i] , sy) - 1.0 * luat + 1.0;
                luat--;
                sx-=a[i];
            }
        }
        else {
            if (sol < min(sx , sy - b[i]) - 1.0 * luat + 1.0){
                sol = min(sx , sy - b[i]) - 1.0 * luat + 1.0;
                luat--;
                sy-=b[i];
            }
        }
    }
    cout << setprecision(4) << fixed << sol;
    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:10:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d",&n);
     ~~~~~~~^~~~~~~~~~~~~
sure.cpp:13:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%lf%lf",&a[i],&b[i]);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 380 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 380 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 380 KB Output isn't correct
3 Halted 0 ms 0 KB -