Submission #1657601

Source Code Expand

Copy
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 200000000000;
struct edge {int to,cost;};
typedef std::pair<int,int> P;

    int N,C,L[100010],pr,ans;
    bool F[100010];

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>C;
    REP(i,N)cin>>L[i];
    sort(L,L+N);
    pr=0;
    for(int i=N-1;i>=0;i--){
        if(F[i])break;
        if(L[i]+L[pr]+1<=C){
            F[pr]=true;
            pr++;
        }
        F[i]=true;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task C - 収納
User Nafmo2
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1182 Byte
Status
Exec Time 19 ms
Memory 768 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 300 / 300 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 18 ms 768 KB
02.txt 17 ms 768 KB
03.txt 14 ms 768 KB
04.txt 17 ms 768 KB
05.txt 12 ms 768 KB
06.txt 9 ms 768 KB
07.txt 10 ms 768 KB
08.txt 15 ms 768 KB
09.txt 16 ms 768 KB
10.txt 8 ms 768 KB
11.txt 19 ms 768 KB
12.txt 18 ms 768 KB
13.txt 13 ms 768 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB