Submission #89104

# Submission time Handle Problem Language Result Execution time Memory
89104 2018-12-10T10:07:39 Z Lkvatashidze Schools (IZhO13_school) C++17
0 / 100
2000 ms 19148 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=m-1; k>0; 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) {
               ~~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Execution timed out 2056 ms 376 KB Time limit exceeded
2 Execution timed out 2031 ms 380 KB Time limit exceeded
3 Execution timed out 2043 ms 440 KB Time limit exceeded
4 Runtime error 3 ms 692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 3 ms 692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Execution timed out 2036 ms 692 KB Time limit exceeded
7 Execution timed out 2021 ms 1068 KB Time limit exceeded
8 Runtime error 5 ms 1116 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 5 ms 1116 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 5 ms 1260 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 113 ms 1480 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Execution timed out 2104 ms 1584 KB Time limit exceeded
13 Runtime error 27 ms 2496 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Execution timed out 2037 ms 7184 KB Time limit exceeded
15 Execution timed out 2069 ms 14148 KB Time limit exceeded
16 Execution timed out 2051 ms 14348 KB Time limit exceeded
17 Execution timed out 2062 ms 14348 KB Time limit exceeded
18 Execution timed out 2066 ms 14624 KB Time limit exceeded
19 Execution timed out 2029 ms 16172 KB Time limit exceeded
20 Execution timed out 2043 ms 19148 KB Time limit exceeded