답안 #682297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
682297 2023-01-16T05:53:54 Z MilosMilutinovic Happiness (Balkan15_HAPPINESS) C++14
30 / 100
2000 ms 13996 KB
#include "happiness.h"
#include <bits/stdc++.h>
 
using namespace std;
 
multiset<long long> c;
 
bool Process(multiset<long long> st) {
  vector<long long> v;
  for (auto x : st) {
    v.push_back(x);
  }
  vector<long long> pref(1, 1);
  for (auto x : st) {
    pref.push_back(pref.back() + x);
  }
  for (int i = 0; i < (int) v.size(); i++) {
    if (pref[i] < v[i] && (i == 0 || v[i] != v[i - 1])) {
      return false;
    }
  }
  return true;
}
 
bool init(int coinsCount, long long maxCoinSize, long long coins[]) {
  for (int i = 0; i < coinsCount; i++) {
    c.insert(coins[i]);
  }
  return Process(c);
}
 
bool is_happy(int event, int coinsCount, long long coins[]) {
  if (event == -1) {
    for (int i = 0; i < coinsCount; i++) {
      c.erase(c.find(coins[i]));
    }
  } else {
    for (int i = 0; i < coinsCount; i++) {
      c.insert(coins[i]);
    }
  }
  return Process(c);
}

Compilation message

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 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 304 KB Output is correct
6 Correct 8 ms 448 KB Output is correct
7 Correct 8 ms 444 KB Output is correct
8 Correct 675 ms 1956 KB Output is correct
9 Correct 681 ms 1928 KB Output is correct
10 Correct 693 ms 1960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 304 KB Output is correct
6 Execution timed out 2024 ms 13996 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 304 KB Output is correct
6 Correct 8 ms 448 KB Output is correct
7 Correct 8 ms 444 KB Output is correct
8 Correct 675 ms 1956 KB Output is correct
9 Correct 681 ms 1928 KB Output is correct
10 Correct 693 ms 1960 KB Output is correct
11 Execution timed out 2024 ms 13996 KB Time limit exceeded
12 Halted 0 ms 0 KB -