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.

Atcorder153 A~C問題

Posted at

Atcorder153
https://atcoder.jp/contests/abc153/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(){
    int H,A; cin >> H >> A;
    int ans=H/A;
    if (H%A!=0) ans++;
    cout << ans << 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 H,N; cin >> H >> N;
    vector <int> A(N);
    int sum=0;
    rep(i,N){
        cin >> A[i];
        sum+=A[i];
    } 
    
    if (sum>=H) cout << "Yes" << endl;
    else cout << "No" << 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,K; cin >> N >> K;
    vector <int> H(N);
    rep(i,N) cin >> H[i];
    
    ll ans=0;
    sort(H.begin(),H.end());
    rep(i,N-K) ans+=H[i];
    
    cout << ans << endl;
    return 0;
}
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?