Codeforces Round #415 (Div. 2), problem: (E) Find a car Solution In JAVA

By |2017-07-24T16:57:47+00:00July 24th, 2017|Categories: Java, Programming|Tags: , , |

import java.util.*; public class C{ final int MOD = (int)1e9 + 7; long get(int x, int y, int lim){ if (Math.min(x,y) < 0) return 0L; long[][][][] d = new long[32][2][2][2], sm = new long[32][2][2][2]; d[31][1][1][1] = 1; for (int w = 30; w >= [...]

Codeforces Round #415 (Div. 2), problem: (D) Glad to see you! Solution In C/C++

By |2017-07-24T16:55:40+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , |

#include <cstdio> using namespace std; #define ff fflush(stdout) #define mid (lef+rig>>1) int n, k, x, t1, t2; char s[5]; inline bool I(int a, int b){printf("1 %d %d\n",a,b), ff, scanf("%s",s); return s[0]=='T';} inline int Binary(int lef, int rig){if(lef>rig) return 0; for(; rig-lef > 1; I(mid,mid+1) [...]

Codeforces Round #415 (Div. 2), problem: (C) Do you want a date? Solution In C/C++

By |2017-07-24T16:54:19+00:00July 24th, 2017|Categories: Uncategorized|Tags: , , , , , , , |

#include <bits/stdc++.h> using namespace std; long long n,a[300007],r[300007],m=1e9+7,sum=0; int main(){ std::cin >> n;r[0] = 1; for(int i = 0;i<n;i++)cin>>a[i],r[i+1]=(r[i]*2)%m; sort(a,a+n); for(int i=0;i<n;i++) sum+=(a[i]*(r[i]-r[n-i-1]))%m,sum%=m; cout << sum%m; }

Codeforces Round #415 (Div. 2), problem: (B) Summer sell-off Solution In C/C++

By |2017-07-24T16:52:53+00:00July 24th, 2017|Categories: Uncategorized|Tags: , , , , , , , |

#include<bits/stdc++.h> using namespace std; int64_t n,f,k,l,i,w,s,a[100179]; int main(){ for(cin>>n>>f;i<n;i++)cin>>k>>l,w=min(k,l),a[i]=min(2*k,l)-w,s+=w; sort(a,a+n); for(i=0;i<n;i++)s+=i<f?a[n-1-i]:0; cout<<s; }

Codeforces Round #415 (Div. 2), problem: (A) Straight <> Solution In C/C++

By |2017-07-24T16:51:25+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include <cstdio> int n,k,sum=0,mark; int main() { scanf("%d%d",&n,&k); for(int i=1;i<=n;i++)scanf("%d",&mark),sum+=mark; mark=(n*k-sum)*2-n; if(mark>0)printf("%d",mark); else printf("0"); }