Submission #229548


Source Code Expand

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> P;

const int INF=1<<30;
const long long int INF_=1<<60;

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N,X;
	cin >> N >> X;
	vector<int> cost(N);
	REP(i,0,N) cin >> cost[i];
	int ans=0;
	int cnt=0;
	while(X>0){
		if(X&1==1) ans+=cost[cnt];
		X>>=1;
		++cnt;
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task B - 価格の合計
User walkre
Language C++ (G++ 4.6.4)
Score 100
Code Size 901 Byte
Status AC
Exec Time 27 ms
Memory 932 KB

Compile Error

./Main.cpp:29:29: warning: left shift count >= width of type [enabled by default]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 20
Set Name Test Cases
Sample subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt
All subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt
Case Name Status Exec Time Memory
subtask0_sample01.txt AC 23 ms 924 KB
subtask0_sample02.txt AC 27 ms 800 KB
subtask0_sample03.txt AC 22 ms 928 KB
subtask1_01.txt AC 24 ms 928 KB
subtask1_02.txt AC 24 ms 932 KB
subtask1_03.txt AC 24 ms 800 KB
subtask1_04.txt AC 22 ms 928 KB
subtask1_05.txt AC 23 ms 924 KB
subtask1_06.txt AC 23 ms 924 KB
subtask1_07.txt AC 26 ms 928 KB
subtask1_08.txt AC 23 ms 924 KB
subtask1_09.txt AC 24 ms 928 KB
subtask1_10.txt AC 24 ms 924 KB
subtask1_11.txt AC 22 ms 804 KB
subtask1_12.txt AC 24 ms 924 KB
subtask1_13.txt AC 23 ms 928 KB
subtask1_14.txt AC 24 ms 924 KB
subtask1_15.txt AC 23 ms 924 KB
subtask1_16.txt AC 24 ms 924 KB
subtask1_17.txt AC 24 ms 844 KB