AtCoder Beginner Contest 113

Submission #3539625

Source codeソースコード

#include <bits/stdc++.h>
using namespace std;

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


int solve(int N, int T, int A, vi& H) {
    int diff_min = INT_MAX, diff_min_at = -1;
    T *= 1000;
    A *= 1000;
    rep(i, N) {
        int temp_i = T - 6 * H[i];
        int diff = abs(temp_i - A);
        if (diff < diff_min) {
            diff_min = diff;
            diff_min_at = 1+i;
        }
    }
    return diff_min_at;
}

int main() {
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    vi H(N);
    rep(i, N) cin >> H[i];
    cout << solve(N, T,A, H) << endl;
    return 0;
}

Submission

Task問題 B - Palace
User nameユーザ名 naoya_t
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 200
Source lengthソースコード長 1685 Byte
File nameファイル名
Exec time実行時間 2 ms
Memory usageメモリ使用量 256 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt
All 200 / 200 01.txt,02.txt,03.txt,04.txt,05.txt,06.txt,07.txt,08.txt,09.txt,10.txt,sample_01.txt,sample_02.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01.txt AC 2 ms 256 KB
02.txt AC 2 ms 256 KB
03.txt AC 2 ms 256 KB
04.txt AC 2 ms 256 KB
05.txt AC 2 ms 256 KB
06.txt AC 2 ms 256 KB
07.txt AC 2 ms 256 KB
08.txt AC 2 ms 256 KB
09.txt AC 2 ms 256 KB
10.txt AC 2 ms 256 KB
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB