답안 #824388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824388 2023-08-14T05:08:56 Z Amylopectin Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
2 ms 340 KB
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int mxn = 2010;
struct we
{
    double aa,bb;
    int idx;
};
bool cmp1(const struct we &l,const struct we &r)
{
    return l.aa < r.aa;
}
bool cmp2(const struct we &l,const struct we &r)
{
    if(l.bb == -1)
    {
        return false;
    }
    if(r.bb == -1)
    {
        return true;
    }
    if(l.bb == r.bb)
    {
        return l.aa > r.aa;
    }
    return l.bb < r.bb;
}
struct we soa[mxn] = {},sob[mxn] = {};
int u[mxn] = {};
int main()
{
    int i,j,n,m,cn,cm,fn,fm,cou;
    double cva,cmi,f,p;
    scanf("%d %d",&n,&m);
    for(i=0; i<n; i++)
    {
        scanf("%lf %lf",&soa[i].aa,&soa[i].bb);
        soa[i].idx = i;
        sob[i] = {soa[i].aa,soa[i].bb,i};
    }
    sort(soa,soa+n,cmp1);
    sort(sob,sob+n,cmp2);
    for(i=0; i<n; i++)
    {
        if(i > 0 && sob[i-1].bb == -1)
        {
            break;
        }
        cva = 0;
        for(j=0; j<i; j++)
        {
            u[sob[j].idx] = 1;
            f = j + 1;
            cva += sob[j].bb / f;
        }
        f = i+1;
        cou = i;
        for(j=0; j<n; j++)
        {
            if(u[soa[j].idx] == 0)
            {
                cou ++;
                cva += soa[j].aa / f;
            }
            if(cou == m)
            {
                break;
            }
        }
        if(i == 0)
        {
            cmi = cva;
        }
        else 
        {
            cmi = min(cmi,cva);
        }
    }
    printf("%lf\n",cmi);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:17: warning: unused variable 'cn' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                 ^~
Main.cpp:35:20: warning: unused variable 'cm' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                    ^~
Main.cpp:35:23: warning: unused variable 'fn' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                       ^~
Main.cpp:35:26: warning: unused variable 'fm' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                          ^~
Main.cpp:36:22: warning: unused variable 'p' [-Wunused-variable]
   36 |     double cva,cmi,f,p;
      |                      ^
Main.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
Main.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%lf %lf",&soa[i].aa,&soa[i].bb);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Incorrect 1 ms 212 KB Output isn't correct
30 Halted 0 ms 0 KB -