| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 905115 | Ahmed57 | Reconstruction Project (JOI22_reconstruction) | C++17 | 1595 ms | 64184 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
//freopen("input.txt","r",stdin);
//freopen("outout.txt","w",stdout);
int n,m;
cin>>n>>m;
vector<int> v[n];
int cool[n];
long long smaller =0 , greater = 0;
long long cntsm = 0 , cntlr = 0;
for(int i = 0;i<m;i++){
int a,b,c;
cin>>a>>b>>c;
v[a].push_back(c);
}
vector<pair<int,int>> pts;
for(int i = 1;i<n;i++){
sort(v[i].begin(),v[i].end());
pts.push_back({0,i});
for(int j = 0;j<v[i].size();j++){
pts.push_back({v[i][j]+1,i});
pts.push_back({v[i][j],i});
}
for(int j = 1;j<v[i].size();j++){
pts.push_back({(v[i][j]+v[i][j-1])/2+1,i});
pts.push_back({(v[i][j]+v[i][j-1])/2,i});
}
cool[i] = 0;
}
sort(pts.begin(),pts.end());
int q;
cin>>q;
long long ans[q];
vector<pair<int,int>> qu;
for(int i = 0;i<q;i++){
int c;cin>>c;
qu.push_back({c,i});
}
sort(qu.begin(),qu.end());
int ind = 0;
for(auto i:qu){
while(ind<pts.size()&&pts[ind].first<=i.first){
int an = pts[ind].second;
if(cool[an]!=0){
if(cool[an]>0){
greater-=cool[an];
cntlr--;
}else{
smaller+=cool[an];
cntsm--;
}
}
int it = lower_bound(v[an].begin(),v[an].end(),i.first)-v[an].begin();
if(it==v[an].size()){
it--;
cool[an] = -v[an][it];
smaller+=v[an][it];
cntsm++;
}else if(it==0){
cool[an] = v[an][it];
greater+=v[an][it];
cntlr++;
}else{
if(abs(v[an][it]-i.first)<=abs(v[an][it-1]-i.first)){
cool[an] = v[an][it];
greater+=v[an][it];
cntlr++;
}else{
it--;
cool[an] = -v[an][it];
smaller+=v[an][it];
cntsm++;
}
}
ind++;
}
ans[i.second] = greater-smaller-i.first*cntlr+i.first*cntsm;
}
for(int i = 0;i<q;i++){
cout<<ans[i]<<endl;
}
}컴파일 시 표준 에러 (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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
