# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
23563 | 2017-05-12T15:12:45 Z | TAMREF | Fireworks (APIO16_fireworks) | C++11 | 3 ms | 9052 KB |
#include <bits/stdc++.h> #define va first #define vb second using namespace std; typedef long long ll; typedef pair<int,int> pii; const ll INF=1<<45; const int MX=300005; int N,M; vector<pii> G[300005]; void input(){ scanf("%d%d",&N,&M); for(int i=2,x,y;i<=N+M;i++){ scanf("%d%d",&x,&y); G[i].push_back(make_pair(x,y)); G[x].push_back(make_pair(i,y)); } } void case1(){ int p=0,q,r,s=INT_MAX; auto pro = [=](int x)->ll{ ll S=0; for(pii u : G[1]){ S+=llabs((ll)u.vb-x); //cout<<u.va<<' '<<u.vb<<" : "<<S<<endl; } return S; }; while(p<s){ q=p+(s-p)/3,r=s-(s-p)/3; if(pro(q)<=pro(r)) s=r-1; else p=q+1; } printf("%lld\n",pro(p)); exit(0); } int main(){ input(); if(N==1) case1(); else return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9052 KB | Output is correct |
2 | Correct | 0 ms | 9052 KB | Output is correct |
3 | Correct | 3 ms | 9052 KB | Output is correct |
4 | Correct | 3 ms | 9052 KB | Output is correct |
5 | Correct | 3 ms | 9052 KB | Output is correct |
6 | Correct | 0 ms | 9052 KB | Output is correct |
7 | Correct | 3 ms | 9052 KB | Output is correct |
8 | Correct | 3 ms | 9052 KB | Output is correct |
9 | Correct | 3 ms | 9052 KB | Output is correct |
10 | Correct | 0 ms | 9052 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 9052 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9052 KB | Output is correct |
2 | Correct | 0 ms | 9052 KB | Output is correct |
3 | Correct | 3 ms | 9052 KB | Output is correct |
4 | Correct | 3 ms | 9052 KB | Output is correct |
5 | Correct | 3 ms | 9052 KB | Output is correct |
6 | Correct | 0 ms | 9052 KB | Output is correct |
7 | Correct | 3 ms | 9052 KB | Output is correct |
8 | Correct | 3 ms | 9052 KB | Output is correct |
9 | Correct | 3 ms | 9052 KB | Output is correct |
10 | Correct | 0 ms | 9052 KB | Output is correct |
11 | Incorrect | 0 ms | 9052 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9052 KB | Output is correct |
2 | Correct | 0 ms | 9052 KB | Output is correct |
3 | Correct | 3 ms | 9052 KB | Output is correct |
4 | Correct | 3 ms | 9052 KB | Output is correct |
5 | Correct | 3 ms | 9052 KB | Output is correct |
6 | Correct | 0 ms | 9052 KB | Output is correct |
7 | Correct | 3 ms | 9052 KB | Output is correct |
8 | Correct | 3 ms | 9052 KB | Output is correct |
9 | Correct | 3 ms | 9052 KB | Output is correct |
10 | Correct | 0 ms | 9052 KB | Output is correct |
11 | Incorrect | 0 ms | 9052 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |