Educational Codeforces Round 55 (Rated for Div. 2)

http://codeforces.com/contest/1082

A题

#include 
using namespace std;
typedef long long ll;
const int N = 105;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main()
{
    int n, x, y, d;
    int T;
    cin >> T;
    while(T --){

        cin >> n >> x >> y >> d;

        if(abs(y-x)%d == 0){
            cout << abs(y-x)/d <<'\n';
        }else{

            int ans=INF;

            if ((y-1)%d==0)
                ans=min(ans,(x-1+d-1)/d+(y-1)/d);

            if ((n-y)%d==0)
                ans=min(ans,(n-x+d-1)/d+(n-y)/d);

            if (ans==INF)
                ans=-1;

            cout<

B题

#include 
using namespace std;
typedef long long ll;
const int N = 105;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int sum=0;
    int l=0;
    int mx=0;
    int num=0;
    for (int r=0;r1)
        {
            if (s[l]=='S')sum--;
            l++;
        }
        mx=max(mx,r-l+1);
    }
    cout<

C题

#include 
using namespace std;
typedef long long ll;
const int N = 105;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
ll res [100010];
vectorg[100010];
int main()
{
	int n,m;
	ll maxl = 0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
	}
	for(int i=1;i<=m;i++)
	sort(g[i].begin(),g[i].end(),greater());
	for(int i = 1 ;i<=m;i++)
	{
		ll temp  = 0;
		for(int j=0;j=0) res[j+1] += temp;
			else break;
		}
	}
	for(int i=1;i<=n;i++)
	maxl = max(maxl,res[i]);
	printf("%I64d\n",maxl);
	return 0;
}

 

你可能感兴趣的:(Codeforces)