huangyu's blog

By huangyu, history, 9 years ago, In English

http://codeforces.me/problemset/problem/780/A 这题目难点在于设置bool数组 袜子存进去就设置为true

###

#include <bits/stdc++.h>
using namespace std;
bool a[100000];
int main()
{
    int n,sum=0,al=0;
    memset(a,false,100000);
    cin>>n;
    int t;
    for(int i=0;i<2*n;i++){
        cin>>t;
        if(!a[t]){
            sum++;
            al=max(al,sum);
            a[t]=true;
        }
        else
            sum--;

    }
    cout<<al<<endl;
    return 0;
}

Full text and comments »

  • Vote: I like it
  • -23
  • Vote: I do not like it

By huangyu, history, 9 years ago, In English

http://codeforces.me/problemset/problem/724/A 字符串比较是否相等 string用== char用strcmp 相等为0 不等为1

#include <bits/stdc++.h>
using namespace std;
char s[7][15]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
int main()
{
    char a[2][15];
    int b[2];
    int i,j;
    cin>>a[0];
    cin>>a[1];
    for(j=0;j<2;j++)
    for(i=0;i<7;i++){
        if(!strcmp(a[j],s[i])){
            b[j]=i+1;
        }
    }


    if(b[0]==b[1]||(b[0]+2)%7==b[1]%7||(b[0]+3)%7==b[1]%7)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

Full text and comments »

  • Vote: I like it
  • -38
  • Vote: I do not like it