제출 #1117582

#제출 시각아이디문제언어결과실행 시간메모리
1117582vjudge1Paprike (COI18_paprike)C++14
13 / 100
18 ms1500 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define pb push_back #define F first #define S second #define ll long long #define int ll #define pii pair<int, int> #define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define M_PI 3.14159265358979323846 #define all(v) v.begin(), v.end() #define pss pair<string, string> #define no cout<<"No"<<endl; #define yes cout<<"Yes"<<endl; #define imp cout<<-1<<endl; #define flu cout.flush(); #define Endl endl const int N = 300009; const int mod = 1e9+7; void solve(){ int n, k; cin>>n>>k; vector<int>a; for(int i=0; i<n; i++){ int x; cin>>x; a.pb(x); } for(int i=0; i<n-1; i++){ int x, y; cin>>x>>y; } int ans1=0, sum1=0, ans2=0, sum2=0; for(int i=0; i<n; i++){ if(sum1+a[i]>k){ ans1++; sum1=a[i]; } else{ sum1+=a[i]; } } reverse(all(a)); for(int i=0; i<n; i++){ if(sum2+a[i]>k){ ans2++; sum2=a[i]; } else{ sum2+=a[i]; } } cout<<min(ans1, ans2)<<endl; //cout<<ans1<<" "<<ans2<<endl; } signed main(){ io; int t=1; //cin>>t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...