Skip to content

Instantly share code, notes, and snippets.

View Bloofer's full-sized avatar

Joonmo Yang Bloofer

View GitHub Profile
@Bloofer
Bloofer / cctv.cpp
Created April 10, 2020 12:53
cctv
#include <iostream>
#include <climits>
#include <vector>
#include <string>
using namespace std;
int arr[8][8] = { 0, }; // 처음 방안의 벽과 cctv의 위치 배열
int range[8][8] = { 0, }; // cctv의 동작반경
int N, M; // N * M: 배열크기, C: cctv 갯수
vector< pair<int, int> > cctv; // cctv의 배열
promos = [globals()[name] for name in globals()
if name.endswith('_promo')
and name != 'best_promo']
def best_promo(order):
return max(promo(order) for promo in promos)
from abc import ABC, abstractmethod
from collections import namedtuple
Customer = namedtuple('Customer', 'named fidelity')
class LineItem:
def __init__(self, product, quantity, price):
self.product = product
self.quantity = quantity
from abc import ABC, abstractmethod
from collections import namedtuple
Customer = namedtuple('Customer', 'named fidelity')
class LineItem:
def __init__(self, product, quantity, price):
self.product = product
self.quantity = quantity
@Bloofer
Bloofer / multi_thread.py
Created May 30, 2022 16:07
multi_thread
import time
from threading import Thread
COUNT = 50000000
def countdown(n):
while n>0:
n -= 1
t1 = Thread(target=countdown, args=(COUNT//2,))
@Bloofer
Bloofer / single_thread.py
Created May 30, 2022 15:56
single_thread
import time
from threading import Thread
COUNT = 50000000
def countdown(n):
while n>0:
n -= 1
start = time.time()
#include <iostream>
#include <vector>
using namespace std;
int arr[100][100] = {0, };
int N, L;
bool check_slope(vector<int> &v){
// 모든 칸의 높이가 같은 경우 true 반환
bool same = true;
@Bloofer
Bloofer / pq.cpp
Created December 10, 2021 11:09
pq
#include <stdio.h>
#define MAX_N 100001
typedef struct {
int first;
int second;
} pii;
struct pq{
pii heap[MAX_N];
int index[MAX_N];
@Bloofer
Bloofer / fmp.cpp
Last active November 24, 2021 12:46
fmp
class Solution {
private:
bool hash[500001] = {0, };
public:
int firstMissingPositive(vector<int>& nums) {
int cnt;
for (int i=0; i<nums.size(); i++){
if(nums[i] <= 0 || nums[i] > nums.size()) continue;
else hash[nums[i]] = true;
}
@Bloofer
Bloofer / pq.cpp
Last active November 19, 2021 08:49
pq
struct Data{int idx; int value;};
Data db[MAX_N];
int pri[MAX_N];
priority_queue<pair<int, Data*>> PQ;
void find(){
while(!PQ.empty()){
int pri = PQ.top().first;
Data *p = PQ.top().second;
PQ.pop();