Codeforces Round #182 (Div. 2)

简介: //A 好久没做了,5.1一过寝室不熄灯了,今天做了一场还是只做了2题。 弱。#include<iostream>#include<stdio.h>using namespace std;int a[200005],b[200005];int main(){ // freopen("1.txt","r",stdin); int n,m,
//A  好久没做了,5.1一过寝室不熄灯了,今天做了一场还是只做了2题。 弱。
#include<iostream>
#include<stdio.h>
using namespace std;
int a[200005],b[200005];
int main()
{
    // freopen("1.txt","r",stdin);
    int n,m,numx=0,numy=0,x,y;
    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]==1)
            numx++;
        else  numy++;
    }
    for(int j=0; j<m; j++)
    {
        cin>>x>>y;
        if((y-x)%2!=0&&(y-x+1)<=2*min(numx,numy))     // 满足这个条件才输出1
            cout<<1<<endl;
        else
            cout<<0<<endl;
    }
    return 0;
}

//B  
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;
int v[100005],c[100005],t[100005],sum[100005];
int main()
{
    //freopen("1.txt","r",stdin);
    memset(sum,0,sizeof(sum));
    int n,m;
    cin>>n>>m;
    cin>>c[0]>>t[0];
    sum[0]=c[0]*t[0];
    for(int i=1; i<n; i++)
    {
        cin>>c[i]>>t[i];
        sum[i]=c[i]*t[i]+sum[i-1];
    }
    for(int j=0; j<m; j++)
        cin>>v[j];
    int k=0;
    for(int j=0; j<m; j++)
    for(int i=k; i<n; i++)  // 第一次TLE了,这里标记一下从上次的i开始节省了时间。
     if(v[j]<=sum[i])
       {
         cout<<i+1<<endl;
         k=i;
         break;
       }
    return 0;
}

目录
相关文章
|
3月前
|
人工智能 测试技术 芯片
Codeforces Round 963 (Div. 2)
Codeforces Round 963 (Div. 2)
|
机器学习/深度学习 人工智能 移动开发
.Codeforces Round 883 (Div. 3)
Codeforces Round 883 (Div. 3)
|
机器学习/深度学习 人工智能
Codeforces Round 889 (Div. 2)
Codeforces Round 889 (Div. 2)
167 0
|
人工智能
Codeforces Round #786 (Div. 3)(A-D)
Codeforces Round #786 (Div. 3)(A-D)
77 0
Codeforces Round 799 (Div. 4)
Codeforces Round 799 (Div. 4)
123 0
|
人工智能 BI
Codeforces Round 827 (Div. 4)
Codeforces Round 827 (Div. 4)A~G题解
106 0
Codeforces Round 849 (Div. 4)
Codeforces Round 849 (Div. 4)A~G2题解
120 0
|
人工智能
Equidistant Vertices-树型dp-Codeforces Round #734 (Div. 3)
Description A tree is an undirected connected graph without cycles. You are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. e. a k-element subset of vertices) so that all pairwise distances between the selected vertices are equal (in other words,
148 0

热门文章

最新文章