# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
498465 | Yuisuyuno | Palembang Bridges (APIO15_bridge) | C++14 | 42 ms | 7288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Nguyen Huu Hoang Minh
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define reset(x) memset(x, 0,sizeof(x))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define N 100005
#define remain(x) if (x > MOD) x -= MOD
#define ii pair<int, int>
#define iiii pair< ii , ii >
#define viiii vector< iiii >
#define vi vector<int>
#define vii vector< ii >
#define bit(x, i) (((x) >> (i)) & 1)
#define Task "test"
#define int long long
using namespace std;
typedef long double ld;
const int inf = 1e10;
const int minf = -1e10;
int n, k;
struct ppl{
int s, t;
bool operator < (const ppl &a) const{
return s+t < a.s + a.t;
}
};
vector<ppl> Q;
int ans = 0;
void readfile()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
if (fopen(Task".inp","r"))
{
freopen(Task".inp","r",stdin);
//freopen(Task".out","w",stdout);
}
cin >> k >> n;
for(int i=1; i<=n; i++){
char a, b;
int x, y;
cin >> a >> x >> b >> y;
if (a==b) ans += abs(x-y);
else{
Q.pb({x,y});
}
}
}
void solve1(){
vector<int> val;
for(int i=0; i<Q.size(); i++) val.pb(Q[i].s), val.pb(Q[i].t);
sort(all(val));
//val.erase(unique(all(val)),val.end());
int x = val[(val.size()+1)/2 - 1];
for(int i=0; i<Q.size(); i++){
ans += abs(Q[i].s - x) + abs(Q[i].t - x) + 1;
}
//cout << x << '\n';
cout << ans;
}
void proc()
{
if (k==1){
solve1();
return;
}
}
signed main()
{
readfile();
proc();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |