首页 > 代码库 > codeforces--280--
codeforces--280--
其实本场 很水 = =B C都犯了sb错误挂了..
B挂在 自己代码里没有考虑N=1的情况
C挂在 在Int向LL进行强制转换的时候 先溢出了 以后应该这样写 1LL * x * y 或者直接将x y定义为LL
D E porker帮忙= =解释 明天给 睡觉了 3点半了 我擦
B
1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 5 int n , l; 6 const int size = 1010; 7 int a[size]; 8 9 double solve( )10 {11 double ans = max( a[0] , l-a[n-1] );12 for( int i = 1 ; i<n ; i++ )13 {14 ans = max( ans , (a[i]-a[i-1])*1.0/2 );15 }16 return ans;17 }18 19 int main()20 {21 double ans;22 while( ~scanf("%d %d",&n,&l ) )23 {24 for( int i = 0 ; i<n ; i++ )25 {26 scanf( "%d",&a[i] );27 }28 sort( a , a+n );29 ans = solve( );30 printf( "%.10lf\n",ans );31 }32 return 0;33 }
C
1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 5 typedef __int64 LL; 6 const int size = 100010; 7 struct data 8 { 9 int a , b;10 }node[size];11 12 bool cmp( const data p , const data q )13 {14 return p.b < q.b;15 }16 17 int main()18 {19 int r;20 LL ans , sum , temp , n , avg;21 while( ~scanf("%I64d %d %I64d",&n,&r,&avg) )22 {23 sum = 0;24 ans = 0;25 for( int i = 0 ; i<n ; i++ )26 {27 scanf( "%d %d",&node[i].a,&node[i].b );28 sum += node[i].a;29 }30 if( sum >= avg*n )31 {32 printf( "0\n" );33 }34 else35 {36 sum = avg*n - sum;37 sort( node , node+n , cmp );38 for( int i = 0 ; i<n ; i++ )39 {40 if( sum<=0 )41 break;42 if( r-node[i].a > 0 )43 {44 temp = min( (LL)r-node[i].a , sum );45 sum -= temp;46 ans += (LL)(temp * node[i].b);47 }48 }49 printf( "%I64d\n",ans );50 }51 }52 return 0;53 }
D
1 #include <iostream> 2 using namespace std; 3 4 long long gcd(long long a, long long b) { 5 while (b) { 6 long long c = a % b; 7 a = b; 8 b = c; 9 }10 return a;11 }12 13 bool result[2001000];14 15 int main() {16 int n;17 long long x, y;18 cin >> n >> x >> y;19 long long g = gcd(x, y);20 x /= g;21 y /= g;22 long long sum = x + y;23 int shotsA = 0, shotsB = 0;24 for (int i = 1; i < sum; i++) {25 int newshotA = shotsA + 1;26 int newshotB = shotsB + 1;27 if (newshotA * y < newshotB * x) {28 shotsA = newshotA;29 result[i] = true;30 }31 else {32 shotsB = newshotB;33 result[i] = false;34 }35 }36 while (n--) {37 long long a;38 cin >> a;39 a = a % sum;40 if (a == 0 || a == sum - 1) {41 cout << "Both" << endl;42 }43 else if (result[a]) {44 cout << "Vanya" << endl;45 }46 else {47 cout << "Vova" << endl;48 }49 }50 }
E
1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 5 int table[1000010]; 6 int counts[1000010]; 7 8 int main() { 9 int n, m, dx, dy;10 cin >> n >> m >> dx >> dy;11 int y = 0;12 for (int i = 0; i < n; i++) {13 table[n - y] = i;14 y += dy;15 y %= n;16 }17 table[0] = table[n];18 memset(counts, 0, sizeof(counts));19 int result = 0;20 long long locx, locy;21 while (m--) {22 long long x, y;23 cin >> x >> y;24 long long k = table[y];25 long long newx = (x + k * dx) % n;26 counts[newx]++;27 if (counts[newx] > result) {28 result = counts[newx];29 locx = x;30 locy = y;31 }32 }33 cout << locx << " " << locy << endl;34 }
today:
where‘d you go
codeforces--280--
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。