Submission #1846747
Source Code Expand
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
int n,m,r;
int q[100005],w[100005],z[100005];
int main(){
scanf("%d%d",&n,&m);
fore(i,0,n){
int x;
scanf("%d",&x);
q[x]++;
w[x%m]++;
}
fore(i,0,m){
int j=(m-i)%m;
if(i>j)break;
if(i==j){
r+=w[i]/2;
z[i]=w[i]%2;
}
else {
int k=min(w[i],w[j]);
r+=k;z[i]=w[i]-k;z[j]=w[j]-k;
}
}
fore(i,1,100005){
int k=min(q[i],z[i%m])/2;
r+=k;
z[i%m]-=2*k;
}
printf("%d\n",r);
return 0;
}
Submission Info
Submission Time
2017-12-10 07:26:43+0900
Task
D - Pair Cards
User
mjhun
Language
C++14 (GCC 5.4.1)
Score
700
Code Size
858 Byte
Status
AC
Exec Time
12 ms
Memory
1408 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:22:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
./Main.cpp:25:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&x);
^
Judge Result
Set Name
sample
all
Score / Max Score
0 / 0
700 / 700
Status
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, sample-01.txt, sample-02.txt
Case Name
Status
Exec Time
Memory
01-01.txt
AC
2 ms
256 KB
01-02.txt
AC
11 ms
640 KB
01-03.txt
AC
11 ms
640 KB
01-04.txt
AC
11 ms
640 KB
01-05.txt
AC
11 ms
640 KB
01-06.txt
AC
11 ms
640 KB
01-07.txt
AC
11 ms
640 KB
01-08.txt
AC
11 ms
640 KB
01-09.txt
AC
11 ms
640 KB
01-10.txt
AC
12 ms
896 KB
01-11.txt
AC
12 ms
1408 KB
01-12.txt
AC
11 ms
256 KB
01-13.txt
AC
11 ms
384 KB
01-14.txt
AC
11 ms
640 KB
01-15.txt
AC
11 ms
640 KB
01-16.txt
AC
11 ms
640 KB
01-17.txt
AC
11 ms
640 KB
01-18.txt
AC
11 ms
640 KB
01-19.txt
AC
11 ms
768 KB
01-20.txt
AC
12 ms
1408 KB
01-21.txt
AC
11 ms
640 KB
01-22.txt
AC
11 ms
640 KB
01-23.txt
AC
11 ms
640 KB
01-24.txt
AC
11 ms
640 KB
01-25.txt
AC
11 ms
896 KB
01-26.txt
AC
12 ms
1408 KB
01-27.txt
AC
7 ms
1024 KB
01-28.txt
AC
3 ms
1408 KB
01-29.txt
AC
2 ms
896 KB
01-30.txt
AC
2 ms
768 KB
sample-01.txt
AC
2 ms
256 KB
sample-02.txt
AC
2 ms
256 KB