# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
224521 | kshitij_sodani | Lasers (NOI19_lasers) | C++17 | 189 ms | 35308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long int llo;
llo mod=1000000007;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int l,r;
cin>>l>>r;
int x;
vector<int> aa[r];
int y;
for(int i=0;i<r;i++){
cin>>x;
for(int j=0;j<x;j++){
cin>>y;
aa[i].pb(y);
}
}
vector<pair<int,int>> ran;
for(int i=0;i<r;i++){
if(aa[i].size()==0){
continue;
}
int pre[aa[i].size()];
int ss[aa[i].size()];
pre[0]=aa[i][0];
for(int j=1;j<aa[i].size();j++){
pre[j]=pre[j-1]+aa[i][j];
}
ss[aa[i].size()-1]=aa[i][aa[i].size()-1];
for(int j=aa[i].size()-2;j>=0;j--){
ss[j]=ss[j+1]+aa[i][j];
}
for(int j=0;j<aa[i].size();j++){
int st=0;
int e=aa[i][0]-1;
if(j>0){
st=pre[j-1];
e=st+aa[i][j]-1;
}
int st2=l-ss[j];
int e2=st2+aa[i][j]-1;
if(e>=st2){
ran.pb({st2,e});
}
}
}
sort(ran.begin(),ran.end());
int ans=0;
int mi=-1;
int ma=-1;
for(auto nn:ran){
// cout<<nn.a<<" "<<nn.b<<endl;
if(nn.a>ma){
if(ma!=-1){
ans+=ma-mi+1;
}
mi=nn.a;
ma=nn.b;
}
else{
ma=max(ma,nn.b);
}
}
if(ma!=-1){
ans+=ma-mi+1;
}
cout<<ans<<endl;
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |