답안 #534230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534230 2022-03-08T02:38:32 Z LittleOrange Let's Win the Election (JOI22_ho_t3) C++17
5 / 100
2500 ms 324 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool cmp(pair<double,double> a,pair<double,double> b){
    return a.second==b.second?a.first<b.first:(b.second<0&&a.second>=0||a.second>=0&&a.second<b.second);
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<pair<double,double> > dat(n);
    int l = n;
    for (int i = 0;i<n;i++){
        cin >> dat[i].first >> dat[i].second;
        if (dat[i].second<0) l--;
    }
    double ans = 1000000;
    for (int i = 0;i<min(k,l+1);i++){
        double t = 0;
        sort(dat.begin(),dat.end(),cmp);
        for (int j = 0;j<i;j++){
            if (dat[j].second<0){
                t += dat[j].second/(j+1);
            }else{
                t += dat[j].first/(j+1);
                j--;
            }
        }
        sort(dat.begin()+i,dat.end());
        for (int j = i;j<k;j++){
            t += dat[j].first/(i+1);
        }
        ans = min(ans,t);
    }
    cout << fixed << setprecision(15) << ans << "\n";
}

Compilation message

Main.cpp: In function 'bool cmp(std::pair<double, double>, std::pair<double, double>)':
Main.cpp:5:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    5 |     return a.second==b.second?a.first<b.first:(b.second<0&&a.second>=0||a.second>=0&&a.second<b.second);
      |                                                ~~~~~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Execution timed out 2587 ms 204 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Execution timed out 2592 ms 204 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Execution timed out 2592 ms 204 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Execution timed out 2592 ms 204 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2580 ms 312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Execution timed out 2587 ms 204 KB Time limit exceeded
13 Halted 0 ms 0 KB -