Submission #1657924


Source Code Expand

Copy
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    int n, c;
    cin >> n >> c;
    int l[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    
    sort(l, l + n);
    int count = 0;
    int left = 0, right = n - 1;
    while (left <= right) {
        if (left == right) {
            count++;
            break;
        }
        if (l[left] + l[right] + 1 <= c) {
            left++;
            right--;
        } else {
            right--;
        }
        count++;
    }
    cout << count << endl;
    return 0;
}

Submission Info

Submission Time
Task C - 収納
User madman6
Language C++14 (GCC 5.4.1)
Score 300
Code Size 616 Byte
Status
Exec Time 60 ms
Memory 640 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 60 ms 640 KB
02.txt 59 ms 640 KB
03.txt 36 ms 640 KB
04.txt 56 ms 640 KB
05.txt 29 ms 640 KB
06.txt 20 ms 640 KB
07.txt 33 ms 640 KB
08.txt 42 ms 640 KB
09.txt 47 ms 640 KB
10.txt 20 ms 640 KB
11.txt 60 ms 640 KB
12.txt 59 ms 640 KB
13.txt 33 ms 640 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB