Submission #992264


Source Code Expand

#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

lint readL(){
  lint res;
#ifdef ONLINE_JUDGE
  scanf("%I64d",&res);
#else
  scanf("%lld",&res);
#endif
  return res;
}
void printL(lint res){
#ifdef ONLINE_JUDGE
  printf("%I64d",res);
#else
  printf("%lld",res);
#endif
}

//const int INF=5e8;
int n,m;
int ar[100005];

map<int,int> cnt[100005];
int main(){
  cin>>n>>m;
  REP(i,n){
    cin>>ar[i];
    cnt[ar[i]%m][ar[i]]++;
  }
  int res=0;
  REP(i,m/2+1){
    if(i==0 || i*2==m){
      for(auto e:cnt[i]){
        res+=e.sc/2;
      }
    }else{
      int odd1=0,odd2=0;
      int tot1=0,tot2=0;
      for(auto e:cnt[i]){
        tot1+=e.sc;
        if(e.sc&1) ++odd1;
      }
      for(auto e:cnt[m-i]){
        tot2+=e.sc;
        if(e.sc&1) ++odd2;
      }
      if(odd1>odd2){
        swap(odd1,odd2);
        swap(tot1,tot2);
      }
      while(odd2-odd1>=2){
        res+=2;
        odd2-=2;
        tot2-=2;
        tot1-=2;
      }
      res+=(tot1+tot2-odd1-odd2+min(odd1,odd2)*2)/2;
    }
  }
  cout<<res<<endl;
  return 0;
}



Submission Info

Submission Time
Task D - Pair Cards
User hogloid
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2282 Byte
Status WA
Exec Time 77 ms
Memory 9984 KB

Compile Error

./Main.cpp: In function ‘lint readL()’:
./Main.cpp:49:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&res);
                     ^

Judge Result

Set Name sample all
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 10
WA × 22
Set Name Test Cases
sample sample-01.txt, sample-02.txt
all sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt
Case Name Status Exec Time Memory
01-01.txt WA 7 ms 4992 KB
01-02.txt WA 69 ms 8320 KB
01-03.txt WA 69 ms 8320 KB
01-04.txt WA 69 ms 8320 KB
01-05.txt WA 69 ms 8320 KB
01-06.txt WA 68 ms 8320 KB
01-07.txt WA 67 ms 8320 KB
01-08.txt WA 63 ms 8320 KB
01-09.txt WA 60 ms 8320 KB
01-10.txt WA 52 ms 8320 KB
01-11.txt AC 50 ms 8320 KB
01-12.txt AC 40 ms 5376 KB
01-13.txt AC 41 ms 5376 KB
01-14.txt WA 77 ms 9984 KB
01-15.txt WA 77 ms 9984 KB
01-16.txt WA 74 ms 9984 KB
01-17.txt WA 70 ms 9984 KB
01-18.txt WA 67 ms 9984 KB
01-19.txt WA 61 ms 9984 KB
01-20.txt AC 53 ms 9984 KB
01-21.txt WA 49 ms 5504 KB
01-22.txt WA 48 ms 5504 KB
01-23.txt WA 47 ms 5632 KB
01-24.txt WA 44 ms 5504 KB
01-25.txt WA 41 ms 5504 KB
01-26.txt AC 41 ms 5504 KB
01-27.txt AC 30 ms 7424 KB
01-28.txt AC 9 ms 5120 KB
01-29.txt WA 8 ms 4992 KB
01-30.txt AC 8 ms 4992 KB
sample-01.txt AC 7 ms 4992 KB
sample-02.txt AC 7 ms 4992 KB