Submission #1658276


Source Code Expand

#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
int n,c,a;
vector<int> vec;

int main(){
	cin >> n >> c;
	REP(i,0,n) cin >> a,vec.push_back(a);
	sort(vec.begin(),vec.end());
	
	int cou=0,i=0,m=n-1;
	while(n){
		bool f=true;
		RREP(j,m,0)
			if(i!=j&&vec[i]+vec[j]+1<=c){vec.erase(vec.begin()+max(i,j)),vec.erase(vec.begin()+min(i,j)),cou++,n-=2,m=j-2,f=false; break;}
		if(f){cou+=n; break;}
	}
	
	cout << cou << endl;
	return 0;
}

Submission Info

Submission Time
Task C - 収納
User ecasdqina
Language C++14 (GCC 5.4.1)
Score 300
Code Size 621 Byte
Status AC
Exec Time 427 ms
Memory 892 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 16
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt AC 413 ms 892 KB
02.txt AC 411 ms 892 KB
03.txt AC 427 ms 892 KB
04.txt AC 407 ms 892 KB
05.txt AC 382 ms 892 KB
06.txt AC 20 ms 892 KB
07.txt AC 384 ms 892 KB
08.txt AC 395 ms 892 KB
09.txt AC 398 ms 892 KB
10.txt AC 20 ms 892 KB
11.txt AC 412 ms 892 KB
12.txt AC 410 ms 892 KB
13.txt AC 385 ms 892 KB
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB