Submission #1360817


Source Code Expand

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int N, a[MAX];

int main(void) {
    scanf("%d", &N);
    int ma = 0, mi = INF;
    REP(i, N) {
        scanf("%d", a + i);
        chmin(mi, a[i]);
        chmax(ma, a[i]);
    }
    if (ma - mi >= 2) {
        cout << "No" << endl;
        return 0;
    }
    if (ma == mi) {
        if (ma == N - 1 || ma == 1) {
            cout << "Yes" << endl;
            return 0;
        }
        if (N / 2 < ma) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else {
        int cnt[2];
        REP(i, 2) cnt[i] = 0;
        REP(i, N) {
            cnt[a[i] == mi]++;
        }
        if (mi == 1 && cnt[1] == 1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Submission Info

Submission Time
Task B - Colorful Hats
User sekiya9311
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2602 Byte
Status WA
Exec Time 11 ms
Memory 640 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:67:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
                    ^
./Main.cpp:70:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", a + i);
                           ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 6
AC × 22
WA × 2
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
0_03.txt AC 1 ms 256 KB
0_04.txt AC 1 ms 256 KB
0_05.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 9 ms 640 KB
1_03.txt AC 11 ms 640 KB
1_04.txt AC 11 ms 640 KB
1_05.txt AC 11 ms 640 KB
1_06.txt AC 11 ms 640 KB
1_07.txt AC 11 ms 640 KB
1_08.txt AC 9 ms 640 KB
1_09.txt AC 11 ms 640 KB
1_10.txt AC 9 ms 640 KB
1_11.txt WA 11 ms 640 KB
1_12.txt AC 11 ms 640 KB
1_13.txt WA 11 ms 640 KB
1_14.txt AC 11 ms 640 KB
1_15.txt AC 1 ms 256 KB
1_16.txt AC 1 ms 256 KB
1_17.txt AC 11 ms 640 KB