Skip to content

Commit

Permalink
upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ha4219 committed Jan 9, 2023
1 parent 56d513a commit d1a9cc2
Show file tree
Hide file tree
Showing 5 changed files with 260 additions and 19 deletions.
62 changes: 62 additions & 0 deletions boj/boj_27110.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include<bits/stdc++.h>

typedef long long ll;

#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define PII pair<int,int>
#define PIII pair<PII,int>
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a))
#define FOREACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)

#define INF 1e9
#define MAX 1000000000
#define MOD 1000000007

#define N 100001
#define M 101

using namespace std;

int n;
int a,b,c;

int solve() {
cin>>n>>a>>b>>c;

int res = min(a, n) + min(b, n) + min(c, n);

cout<< res<< '\n';
return 0;
}

int main() {
FAST;
int t = 1;
// cin>>t;
TC(t){
solve();
}

return 0;
}
73 changes: 73 additions & 0 deletions boj/boj_27111.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include<bits/stdc++.h>

typedef long long ll;

#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define PII pair<int,int>
#define PIII pair<PII,int>
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a))
#define FOREACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)

#define INF 1e9
#define MAX 200001
#define MOD 1000000007

#define N 100001
#define M 101

using namespace std;

int n;
bool arr[MAX];

int solve() {
cin>>n;
int res = 0;
for (int i=0;i<n;i++) {
int l, r;
cin>>l>>r;
if (arr[l] == r) {
res++;
}
arr[l] = r;
}

for(int i=0;i<MAX;i++) {
if (arr[i]) res++;
}

cout<<res<<'\n';
return 0;
}

int main() {
FAST;
int t = 1;
// cin>>t;
TC(t){
solve();
}

return 0;
}
81 changes: 81 additions & 0 deletions cf/round_839/e.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include<bits/stdc++.h>

typedef long long ll;

#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define PII pair<int,int>
#define PIII pair<PII,int>
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a))
#define FOREACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)

#define INF 1e9
#define MAX 1000000000
#define MOD 1000000007

#define N 100001
#define M 101

using namespace std;

int n;

int solve() {
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
int r = 0; int b = 0; int y = 0;

for(int i=0;i<n;i++) {
if (a[i] != i + 1 && a[i] != n - i) {
y++;
} else if (a[i] != i + 1) {
r++;
} else if (a[i] != n - i) {
b++;
}
}
if (r + y <= b) {
cout<<"First\n";
} else if (b + y < r) {
cout<<"Second\n";
} else {
cout<<"Tie\n";
}
// cout << r << b << y <<'\n';

return 0;
}

int main() {
FAST;
int t;
cin>>t;
TC(t){
solve();
}

return 0;
}
63 changes: 44 additions & 19 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ typedef long long ll;
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define PII pair<int,int>
#define PIII pair<PII,int>
#define PLL pair<ll,ll>
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))
Expand All @@ -30,7 +31,7 @@ typedef long long ll;
#define TC(t) while (t--)

#define INF 1e9
#define MAX 1000000000
#define MAX 100001
#define MOD 1000000007

#define N 100001
Expand All @@ -40,32 +41,56 @@ using namespace std;

int n;

PLL get_max(int t) {
if (t == 0) return {0,0};
ll day = t - (t / 7) * 2;

if (t - (t/7)*7 == 6) {
day--;
} else if(t - (t/7)*7 == 0) {
day -= 2;
}

return {day, t};
}

int solve() {
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
vector<PII> a(n);

for (int i=0;i<n;i++) {
int l, r;
cin>>l>>r;

a[i] = {l, r};
}
int mn = 0, mx=int(1e9);
for(int i=0;i+1<n;i++){
int x = a[i];
int y = a[i+1];
int midL = (x+y)/2;
int midR = (x+y+1)/2;
if (x<y)
mx = min(mx, midL);
if (x>y)
mn = max(mn, midR);

sort(a.begin(), a.end());

int t = 0;
PLL md = {-1, -1};
int res = 0;
int residual = 0;
for(int i=0;i<n;i++) {
t += a[i].se;
md = get_max(a[i].fi);
cout<<md.fi<<" "<<md.se<<'\n';
if (t > md.fi + md.se) {
cout<<"-1\n";
return 0;
}
res += t - md.fi - residual;
residual -= md.fi - t;

}
if (mn<=mx) cout<<mn<<'\n';
else cout<<-1<<'\n';
return 0;
cout<<res<<'\n';
return 0;
}

int main() {
FAST;
int t;
cin>>t;
int t = 1;
// cin>>t;
TC(t){
solve();
}
Expand Down
Binary file modified main.exe
Binary file not shown.

0 comments on commit d1a9cc2

Please sign in to comment.