답안 #167361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167361 2019-12-07T15:57:36 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,ans=0;
      cin>>n>>m;
      map<int,vector<ii>>arr;
      map<int,set<int>>Q;
      for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            arr[x].pb({y,i+1});
            Q[y].insert(i+1);
      }
      for(int i=0;i<m;i++){
            int x;
            cin>>x;
            arr[x].pb({0,0});
      }
      for(map<int,vector<ii>>::reverse_iterator itr=arr.rbegin();itr!=arr.rend();itr++){
            vector<ii>&W=itr->second;
            for(int i=0;i<W.size();i++){
                  if(W[i].second==0&&!Q.empty()){
                        Q.rbegin()->second.erase(--Q.rbegin()->second.end());
                        if(Q.rbegin()->second.empty())Q.erase(--Q.end());
                        ans++;
                  }
            }
            for(int i=0;i<W.size();i++){
                  if(W[i].second>0&&Q.count(W[i].first)&&Q[W[i].first].count(W[i].second)){
                        Q[W[i].first].erase(W[i].second);
                        if(Q[W[i].first].empty())Q.erase(W[i].first);
                  }
            }
      }
      cout<<ans;
}

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:41: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 Incorrect 2 ms 376 KB Output isn't correct
4 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 Incorrect 2 ms 376 KB Output isn't correct
4 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 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -