제출 #1120973

#제출 시각아이디문제언어결과실행 시간메모리
1120973vjudge1Uplifting Excursion (BOI22_vault)C++17
0 / 100
5057 ms8304 KiB
#include<bits/stdc++.h> #define pb push_back #define pf push_front #define mp make_pair #define F first #define S second #define ff first #define ss second #define str string #define ll int #define ull unsigned ll #define ld long double #define pll pair<ll,ll> #define plll pair<pll,ll> #define pllll pair<pll,pll> #define pii pair<int,int> #define pld pair<ld,ld> #define vl vector<ll> #define vll vector<pll> #define vlll vector<plll> #define vllll vector<pllll> #define vb vector<bool> #define vi vector<int> #define vii vector<pii> #define sz(x) (ll)(x).size() #define fr front() #define tp top() #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define bk back(); #pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") using namespace std; const ld pi=acos(-1.0); const ll e5=1e5; const ll e6=1e6; const ll e9=1e9; const ll inf=1e18; const ll mod=1e9+7; const ll mod2=998244353; const ll MOD=106710087877475399; const ll N=1e3+10; const ll M=1e6+10; const ld eps=1e-9; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll bpm(ll x,ll y,ll m){if(y==0)return 1%m;ll p=bpm(x,y/2,m); if(y%2==0)return p*p%m;else return p*p%m*x%m;} ll bp(ll x,ll y){if(y==0)return 1;ll p=bp(x,y/2); if(y%2==0)return p*p;else return p*p*x;} ll n,L,a[N],dp[M][2]; void solve(){ cin>>n>>L; vl v; for(ll i=-n;i<=n;i++){ ll x; cin>>x; for(ll j=1;j<=x;j++) v.pb(i); } for(ll i=0;i<=1e6;i++) dp[i][1]=-inf; dp[5*e5][1]=0; for(ll i=0;i<sz(v);i++){ ll i2=i%2; for(ll j=0;j<=1e6;j++){ dp[j][i2]=dp[j][i2^1]; if(0<=j-v[i]&&j-v[i]<=1e6) dp[j][i2]=max(dp[j][i2],dp[j-v[i]][i2^1]+1); } } if(L>5*e5||L<-5*e5||dp[L+5*e5][1-sz(v)%2]<0) cout<<"impossible"; else cout<<dp[L+5*e5][1-sz(v)%2]; return; } int main(/*Aldk*/){ ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen("01.in", "r", stdin); //freopen("01.out ", "w", stdout); //cout<<setprecision(6)<<fixed; int test=1; //cin>>test; for(int i=1;i<=test;i++){ solve(); cout<<'\n'; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

vault.cpp:38:14: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   38 | const ll inf=1e18;
      |              ^~~~
vault.cpp:41:14: warning: overflow in conversion from 'long int' to 'int' changes value from '106710087877475399' to '1910717511' [-Woverflow]
   41 | const ll MOD=106710087877475399;
      |              ^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...