Submission #5866197


Source Code Expand

#include <iostream>
#include <cstdio>
#include <set>
using namespace std;

int main(int argc, char *argv[])
{
    int n;
    int p;
    set<int> s;
    s.insert(0);
    cin>>n;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &p);
        set<int> newset;
        for (auto c : s) {
            newset.insert(c + p);
        }
        for (auto c: newset) {
            s.insert(c);
        }
    }
    printf("%d\n", s.size());
    return 0;
}

Submission Info

Submission Time
Task A - コンテスト
User vintersnow
Language C++14 (GCC 5.4.1)
Score 2
Code Size 475 Byte
Status AC
Exec Time 42 ms
Memory 768 KB

Compile Error

./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:23:28: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::set<int>::size_type {aka long unsigned int}’ [-Wformat=]
     printf("%d\n", s.size());
                            ^
./Main.cpp:14:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &p);
                        ^

Judge Result

Set Name All
Score / Max Score 2 / 2
Status
AC × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 AC 1 ms 256 KB
01 AC 12 ms 512 KB
02 AC 42 ms 768 KB
90 AC 1 ms 256 KB
91 AC 1 ms 256 KB