답안 #1019685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1019685 2024-07-11T07:22:57 Z NoLove Happiness (Balkan15_HAPPINESS) C++14
0 / 100
0 ms 348 KB
/**
 *    author : Lăng Trọng Đạt
 *    created: 11-07-2024 
**/
#include <bits/stdc++.h>
#include "happiness.h"
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;
using vi = vector<int>;
#define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
void mx(int& a, int b) { if (b > a) a = b; }
void mi(int& a, int b) { if (b < a) a = b; }
#define si(x) (int)(x.size())
const int INF = 1e18;
const int MOD = 1e9 + 7;


multiset<int> vals;
bool init(int coinsCount, long long maxCoinSize, long long coins[]) {
    FOR(i, 0, coinsCount - 1)
        vals.insert(coins[i]);
	return true;
}
bool is_happy(int event, int coinsCount, long long coins[]) {
    db(vals)
    FOR(i, 0, coinsCount - 1)
        if (event == 1)
            vals.insert(coins[i]);
        else vals.erase(vals.find(coins[i]));
    db(vals)
    long long s = 1;
    for (int i : vals) {
        if (s < i) return false;
        s += i;
    }
	return true;
}

Compilation message

happiness.cpp:22:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   22 | const int INF = 1e18;
      |                 ^~~~
happiness.cpp: In function 'bool init(int, long long int, long long int*)':
happiness.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
happiness.cpp:28:5: note: in expansion of macro 'FOR'
   28 |     FOR(i, 0, coinsCount - 1)
      |     ^~~
happiness.cpp:18:22: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                      ^~~
happiness.cpp:28:5: note: in expansion of macro 'FOR'
   28 |     FOR(i, 0, coinsCount - 1)
      |     ^~~
happiness.cpp:30:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   30 |  return true;
      |  ^~~~~~
happiness.cpp: In function 'bool is_happy(int, int, long long int*)':
happiness.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
happiness.cpp:34:5: note: in expansion of macro 'FOR'
   34 |     FOR(i, 0, coinsCount - 1)
      |     ^~~
grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
   16 |  long long max_code;
      |            ^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -