답안 #167353

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167353 2019-12-07T15:03:02 Z theStaticMind Exhibition (JOI19_ho_t2) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,m;
      cin>>n>>m;
      map<int,vector<ii>>arr;
      multiset<int>ans;
      for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            arr[x].pb({y,1});
      }
      for(int i=0;i<m;i++){
            int x;
            cin>>x;
            arr[x].pb({0,0});
      }
      priority_queue<int,vector<int>,greater<int>>Q;
      for(map<int,vector<ii>>::iterator itr=arr.begin();itr!=arr.end();itr++){
            vector<ii>&W=itr->second;
            for(int i=0;i<W.size();i++){
                  if(W[i].second){
                        Q.push(W[i].first);
                  }
            }
            for(int i=0;i<W.size();i++){
                  if(W[i].second==0&&!Q.empty()){
                        int v=Q.top();Q.pop();
                        multiset<int>::iterator ptr=ans.upper_bound(v);
                        if(ptr==ans.end())ans.insert(v);
                        else{
                              ans.erase(ptr);
                              ans.insert(v);
                        }
                  }
            }
      }
      cout<<ans.size();
}

Compilation message

joi2019_ho_t2.cpp: In function 'int32_t main()':
joi2019_ho_t2.cpp:34:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i=0;i<W.size();i++){
                         ~^~~~~~~~~
joi2019_ho_t2.cpp:39:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i=0;i<W.size();i++){
                         ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -