답안 #89099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89099 2018-12-10T10:04:20 Z Lkvatashidze 학교 설립 (IZhO13_school) C++17
10 / 100
2000 ms 17952 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

   multiset < pair < ll, ll > > x;
   vector < pair < ll, ll > > v;
   multiset < pair < ll, ll > > st;
   ll n, m, s, ans;

 int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

     ll n, m, s;
      cin >> n >> m >> s;

      for (ll k=1; k<=n; k++) {
         ll z, y;
         cin >> z >> y;
         v.push_back({z,y});
      }

       sort(v.begin(),v.end());
       reverse(v.begin(),v.end());

     for (ll k=0; k<m; k++)
        ans+=v[k].first;

     for (ll k=m; k<n; k++) {
        st.insert({v[k].second,v[k].first});
     }

       while (st.size()>s) {
          st.erase(st.begin());
    }

      set < pair < ll, ll > > ::iterator st_it;
      for (st_it=st.begin(); st_it!=st.end(); st_it++)
        ans+=(*st_it).first;

       set < pair < ll, ll > > st1;
      while (!st.empty()) {
         st1.insert({-(*st.begin()).first,(*st.begin()).second});
         st.erase(st.begin());
      }

     for (ll k=0; k<m; k++) {

      while (true) {
           bool ind1=false;
        set < pair <ll, ll > > ::iterator st_it;
    for (st_it=st1.begin(); st_it!=st1.end(); st_it++) {
          if (ans<ans-v[k].first+v[k].second+(*st_it).first+(*st_it).second) {
             ans+=((*st_it).first+(*st_it).second);
             ans-=(v[k].first-v[k].second);
             st1.erase(st_it);
             st1.insert({-v[k].second,v[k].first});
             ind1=true;
             break;
            }
    }
          if (!ind1) break;
    }
}
      cout << ans;

    return 0;
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:35:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
        while (st.size()>s) {
               ~~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Incorrect 0 ms 516 KB Output isn't correct
5 Incorrect 2 ms 576 KB Output isn't correct
6 Incorrect 2 ms 620 KB Output isn't correct
7 Incorrect 10 ms 876 KB Output isn't correct
8 Incorrect 5 ms 876 KB Output isn't correct
9 Incorrect 13 ms 876 KB Output isn't correct
10 Incorrect 7 ms 876 KB Output isn't correct
11 Incorrect 73 ms 892 KB Output isn't correct
12 Incorrect 58 ms 1020 KB Output isn't correct
13 Incorrect 530 ms 1784 KB Output isn't correct
14 Execution timed out 2055 ms 6252 KB Time limit exceeded
15 Incorrect 229 ms 13112 KB Output isn't correct
16 Execution timed out 2033 ms 13432 KB Time limit exceeded
17 Execution timed out 2028 ms 13432 KB Time limit exceeded
18 Execution timed out 2032 ms 13704 KB Time limit exceeded
19 Execution timed out 2021 ms 15284 KB Time limit exceeded
20 Execution timed out 2021 ms 17952 KB Time limit exceeded