Skip to content

Commit

Permalink
AtCoderの提出コード
Browse files Browse the repository at this point in the history
  • Loading branch information
Mten7271 committed Jun 25, 2022
1 parent 8014d17 commit 48cad6f
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
34 changes: 34 additions & 0 deletions 20170916_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 n, k;
cin >> n >> k;
vi x(n);
REP(i, n) cin >> x[i];
// (x[i], i)のボールに対する移動距離の総和算出
int typeA = 0, typeB = 0, minDistance = 0;
REP(i, n){
typeA = x[i] * 2;
typeB = abs(x[i] - k) * 2;
minDistance += min(typeA, typeB);
}
PRINT(minDistance)
return 0;
}
33 changes: 33 additions & 0 deletions 20180218_b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#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 n;
cin >> n;
vi a(n);
REP(i, n) cin >> a[i];
sort(ALL(a));
int alice = 0, bob = 0;
for(int i=n-1; i >= 0; i -= 2){
alice += a[i];
bob += a[i-1];
}
PRINT(alice - bob)
return 0;
}
28 changes: 28 additions & 0 deletions 20220625_c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#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 n;
string S;
cin >> n >> S;
vll W(n);
REP(i, n) cin >> W[i];

return 0;
}

0 comments on commit 48cad6f

Please sign in to comment.