Submission #289712

#TimeUsernameProblemLanguageResultExecution timeMemory
289712b00n0rp선물상자 (IOI15_boxes)C++17
100 / 100
574 ms298232 KiB
/*input 3 2 8 1 2 5 */ #include<bits/stdc++.h> using namespace std; #define ll long long #define int ll #define pb push_back #define INF 1000000000 #define MOD 1000000007 #define mp make_pair const double PI=3.141592653589793238462643383279502884197169399375105820974944; #define REP(i,n) for (int i = 0; i < n; i++) #define FOR(i,a,b) for (int i = a; i < b; i++) #define REPD(i,n) for (int i = n-1; i >= 0; i--) #define FORD(i,a,b) for (int i = a; i >= b; i--) #define remax(a,b) a = max(a,b) #define remin(a,b) a = min(a,b) #define all(v) v.begin(),v.end() #define pii pair<int,int> #define F first #define S second #define mii map<int,int> #define vi vector<int> #define vvi vector<vi> #define itr :: iterator it #define WL(t) while(t --) #define gcd(a,b) __gcd((a),(b)) #define lcm(a,b) ((a)*(b))/gcd((a),(b)) #define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl; #define debug(x) cout << x << endl; #define debug2(x,y) cout << x << " " << y << endl; #define debug3(x,y,z) cout << x << " " << y << " " << z << endl; int power(int a,int b,int m = MOD){ if(b == 0) return 1; if(b == 1) return a; int x = power(a,b/2,m)%m; x = (x*x)%m; if(b%2) return (x*a)%m; return x; } int n,k,l,a[(ll)1e7+5],cw[(ll)1e7+5],acw[(ll)1e7+5]; int delivery(signed N, signed K, signed L, signed p[]){ n = N; k = K; l = L; FOR(i,1,n+1) a[i] = p[i-1]; cw[0] = 0; FOR(i,1,n+1){ if(i <= k) cw[i] = 2*a[i]; else cw[i] = 2*a[i]+cw[i-k]; } acw[n+1] = 0; for(int i = n; i > 0; i --){ if(i+k > n) acw[i] = abs(l-a[i])*2; else acw[i] = abs(l-a[i])*2+acw[i+k]; } int ans = cw[n]; REP(i,n+1){ // cout << i << " " << cw[i] << endl; remin(ans,cw[i]+acw[i+1]); if(i+k <= n) remin(ans,cw[i]+l+acw[i+k+1]); else remin(ans,cw[i]+l); } return ans; }
#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...