0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Atcorder151 A~C問題

Posted at

Atcorder151
https://atcoder.jp/contests/abc151/tasks

#A問題
image.png

A問題.c++
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    char c; cin >> c;
    cout << char(c+1) << endl;
}

#B問題
image.png

B問題.c++
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N,K,M; cin >> N >> K >> M;
    int sum=0;
    vector <int> A(N);
    rep(i,N-1){
        cin >> A[i];
        sum+=A[i];
    }
    
    if(sum/N>=M) cout << 0 << endl;
    else if((sum+K)/N<M) cout << -1 << endl;
    else cout << M*N-sum << endl;
}

#C問題
image.png

C問題.c++
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N,M; cin >> N >> M;
    int A[N+1]; //ACの初期状態
    int B[N+1]; //ACが出るまでのWA数
    rep(i,N+1){
        A[i]=0;
        B[i]=0;
    }
    int AC=0;
    int WA=0;
    
    rep(i,M){
        int a; cin >> a;
        string b; cin >> b;
        
        if(b=="AC" && A[a]==0){
            A[a]=1;
            AC++;
            WA+=B[a];
        }
        if(b=="WA" && A[a]==0) B[a]++;
    }
    cout << AC << " " << WA << endl;
}

#まとめ
・A問題 アスキーコード問題に少し手間取った…

cout << 'a' << endl; 
>> a

cout << char(97) << endl;
>> a

・C問題 問題文をよく注意して読まないと間違える(WAをいくら出しても、その問題でACを一度も出さなかったらWAの数には入れない!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?