Submission #1659900
Source Code Expand
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;
//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
typedef long long ll;
typedef unsigned long long ull;
#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }
const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
//}}}
void solve(){
int N, C;
cin >> N >> C;
vector<int> v;
rep(i, N) {
int t;
cin >> t;
v.push_back(t);
}
sort(all(v));
int cnt = 0;
int ri = N - 1;
for(int i = 0; i <= ri ;i++) {
int fst = v[i];
bool isDouble = false;
if (i == ri) {
cnt ++;
break;
}
for(int j = ri;j > i; j--) {
int lst = v[j];
if (fst + lst + 1 <= C) {
cnt ++;
ri = j - 1;
isDouble = true;
break;
}
cnt ++;
}
if (!isDouble) {
cnt ++;
break;
}
}
cout << cnt << endl;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(12);
solve();
}
Submission Info
| Submission Time |
|
| Task |
C - 収納 |
| User |
attribute_k |
| Language |
C++14 (GCC 5.4.1) |
| Score |
300 |
| Code Size |
2280 Byte |
| Status |
AC |
| Exec Time |
18 ms |
| Memory |
892 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
300 / 300 |
| Status |
|
|
| 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 |
18 ms |
892 KiB |
| 02.txt |
AC |
18 ms |
892 KiB |
| 03.txt |
AC |
14 ms |
892 KiB |
| 04.txt |
AC |
17 ms |
892 KiB |
| 05.txt |
AC |
12 ms |
892 KiB |
| 06.txt |
AC |
8 ms |
892 KiB |
| 07.txt |
AC |
10 ms |
892 KiB |
| 08.txt |
AC |
16 ms |
892 KiB |
| 09.txt |
AC |
16 ms |
892 KiB |
| 10.txt |
AC |
8 ms |
892 KiB |
| 11.txt |
AC |
18 ms |
892 KiB |
| 12.txt |
AC |
18 ms |
892 KiB |
| 13.txt |
AC |
14 ms |
892 KiB |
| sample_01.txt |
AC |
1 ms |
256 KiB |
| sample_02.txt |
AC |
1 ms |
256 KiB |
| sample_03.txt |
AC |
1 ms |
256 KiB |