Skip to content

Commit

Permalink
AtCoderの提出コード
Browse files Browse the repository at this point in the history
  • Loading branch information
Mten7271 committed May 28, 2022
1 parent 4620207 commit a2c9c8a
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 20190106_b.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,22 @@ struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
int n, k;
cin >> n >> k;
vll h(n);
REP(i, n) cin >> h[i];

// dp配列の定義
ll dp[n];
// dp配列の初期化
REP(i, n) dp[i] = INF;
// dp配列の初期条件
dp[0] = 0;
REP2(i, 1, n){
if(i > 1){
REP2(j, 1, k+1) dp[i] = min(dp[i-1], dp[i-k]+abs(h[i]-h[i-j]));
}
}

return 0;
}
26 changes: 26 additions & 0 deletions 20220528_a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define PRINT(n) cout << n << endl;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
int a, b, c;
cin >> a >> b >> c;
if((b >= a && b <= c) || (b <= a && b >= c)) PRINT("Yes")
else PRINT("No")
return 0;
}
34 changes: 34 additions & 0 deletions 20220528_b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define PRINT(n) cout << n << endl;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
int h, w;
cin >> h >> w;
vs S(h);
vector<pii> P;
REP(i, h){
cin >> S[i];
REP(j, w) if(S[i].at(j) == 'o') P.push_back({i, j});
}
// 行-行 + 列-列
int diff = abs(P[0].first - P[1].first) + abs(P[0].second - P[1].second);
PRINT(diff)

return 0;
}
49 changes: 49 additions & 0 deletions 20220528_c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define PRINT(n) cout << n << endl;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
int Q, query_id, x, c;
cin >> Q;
vll S;
map<int, int> count{};
REP(i, Q){
cin >> query_id;
if(query_id == 1){
cin >> x;
S.push_back(x);
count[x]++;
//PRINT("query_id == 1")
sort(ALL(S));
//PRINT("sort")
}else if(query_id == 2){
cin >> x >> c;
int del_num = min(c, count[x]);
vi del_list;
int idx = find(ALL(S), x);
S.erase(S.begin()+idx, S.begin()+idx+del_num);
//REP(i, int(S.size())) PRINT(S[i])
//PRINT("query_id == 2")
}else if(query_id == 3){
//PRINT("query_id == 3")
int S_size = int(S.size());
PRINT(S[S_size-1]-S[0])
}
}
return 0;
}

0 comments on commit a2c9c8a

Please sign in to comment.