# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1124513 | caterpillow | Lasers (NOI19_lasers) | C++17 | 0 ms | 324 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
vector<pii> order;
int n,m,l,ans;
int main(){
freopen("laser.txt","r",stdin);
cin>>l>>n;
for (int i=0;i<n;i++){
vector<int> nw;int rtot=0,ltot=0;
cin>>m;nw.resize(m);
for (int j=0;j<m;j++){
cin>>nw[j];rtot+=nw[j];
}
for (int j=0;j<m;j++){
rtot-=nw[j];
if (l-rtot-ltot<2*nw[j]){
order.push_back({l-rtot-nw[j]+1,ltot+nw[j]});
}
ltot+=nw[j];
}
}
sort(order.begin(),order.end());
if (order.size()==0){
cout<<0;
return 0;
}
int prv=order[0].second,sub=order[0].second-order[0].first;
for (pii i :order){
if (i.second<=prv){
continue;
}
if (i.first>prv){
ans+=sub+1;
sub = i.second-i.first;
prv=i.second;
}
else{
sub+=i.second-prv;
prv=i.second;
}
}
cout<<ans+sub+1;
}
컴파일 시 표준 에러 (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... |