답안 #89057

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

   multiset < pair < int, int > > x;
   vector < pair < int, int > > v;

 int main() {

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

     int n, m, s;
      cin >> n >> m >> s;

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

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

           ll ans=0;

       for (int k=0; k<n; k++) {

        if (s==0 && m==0) break;

         if (s==0) {
           ans+=v[k].first;
           m--;
           continue;
         }

         if (m==0) {
            while (s) {
                ans-=(*x.begin()).second;
                s--;
                x.erase(x.begin());
            }
            continue;
        }

         pair < int, int > p=(*x.begin());
         x.erase(x.begin());

          if (p.first==v[k].first-v[k].second && p.second+v[k].second==0) {
              ans+=v[k].second;
              s--;
        } else {
          ans+=v[k].first;
          m--;
        }
    }

           cout << ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 392 KB Output isn't correct
4 Incorrect 2 ms 408 KB Output isn't correct
5 Incorrect 1 ms 464 KB Output isn't correct
6 Incorrect 2 ms 512 KB Output isn't correct
7 Incorrect 4 ms 768 KB Output isn't correct
8 Incorrect 5 ms 768 KB Output isn't correct
9 Incorrect 6 ms 852 KB Output isn't correct
10 Incorrect 5 ms 852 KB Output isn't correct
11 Incorrect 5 ms 852 KB Output isn't correct
12 Incorrect 5 ms 852 KB Output isn't correct
13 Incorrect 30 ms 2636 KB Output isn't correct
14 Incorrect 78 ms 4804 KB Output isn't correct
15 Incorrect 204 ms 9296 KB Output isn't correct
16 Incorrect 218 ms 10444 KB Output isn't correct
17 Incorrect 224 ms 12664 KB Output isn't correct
18 Incorrect 324 ms 13776 KB Output isn't correct
19 Incorrect 357 ms 14808 KB Output isn't correct
20 Incorrect 455 ms 17068 KB Output isn't correct