Submission #881359
Source Code Expand
/*
Swamy Saranam
Date : 13/09/2016 14:57:03
Author : Krishna Mohan A M
Problem : E - Sequential operations on Sequence
Status :
*/
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ld,ld> pdd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef pair<ll,ll> pl;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define SORT(v) sort((v).begin(),(v).end())
#define UN(v) SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b) memset(a,b,sizeof a)
#define pb push_back
#define x first
#define y second
#define endl "\n"
#define sendl " \n"
#define all(x) (x).begin(), (x).end()
const int mod = 1000000007;
ll a[100005];
int main()
{
FASTIO
int n, q;
cin>>n>>q;
vector<ll> stk;
stk.pb(n);
REP(i, q)
{
ll tmp;
cin>>tmp;
while(!stk.empty() && stk.back() > tmp)
stk.pop_back();
stk.pb(tmp);
}
int k = stk.size();
vector<ll> t(k);
t[k-1] = 1;
for(int i=k-1; i>=0; i--)
{
if(!i){
a[stk[i]] += t[i];
break;
}
ll p = t[i];
ll z = stk[i];
stk[i] = 2e18; //setting it as max value
while(z > stk[0]){
int j = lower_bound(all(stk), z) - stk.begin()-1;
t[j] += p*(z/stk[j]);
z%=stk[j];
}
a[z] += p;
}
for(int i=n-1; i>=0; i--)
a[i] += a[i+1];
FOR(i, 1, n+1)
cout<<a[i]<<endl;
#ifdef LOCAL_DEFINE
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Sequential operations on Sequence |
| User | krishnaanaril |
| Language | C++14 (GCC 5.4.1) |
| Score | 1400 |
| Code Size | 1859 Byte |
| Status | AC |
| Exec Time | 129 ms |
| Memory | 4212 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1400 / 1400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, s1.txt, s2.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 54 ms | 2304 KiB |
| 02.txt | AC | 55 ms | 2432 KiB |
| 03.txt | AC | 55 ms | 2432 KiB |
| 04.txt | AC | 55 ms | 2432 KiB |
| 05.txt | AC | 55 ms | 2432 KiB |
| 06.txt | AC | 86 ms | 4084 KiB |
| 07.txt | AC | 93 ms | 4212 KiB |
| 08.txt | AC | 90 ms | 4212 KiB |
| 09.txt | AC | 96 ms | 4084 KiB |
| 10.txt | AC | 86 ms | 4084 KiB |
| 11.txt | AC | 83 ms | 4212 KiB |
| 12.txt | AC | 94 ms | 4084 KiB |
| 13.txt | AC | 97 ms | 4212 KiB |
| 14.txt | AC | 85 ms | 4084 KiB |
| 15.txt | AC | 83 ms | 4084 KiB |
| 16.txt | AC | 89 ms | 4084 KiB |
| 17.txt | AC | 90 ms | 4212 KiB |
| 18.txt | AC | 87 ms | 4084 KiB |
| 19.txt | AC | 82 ms | 4084 KiB |
| 20.txt | AC | 90 ms | 4212 KiB |
| 21.txt | AC | 129 ms | 2932 KiB |
| 22.txt | AC | 82 ms | 3828 KiB |
| 23.txt | AC | 109 ms | 4084 KiB |
| 24.txt | AC | 62 ms | 4084 KiB |
| 25.txt | AC | 61 ms | 3956 KiB |
| 26.txt | AC | 55 ms | 2932 KiB |
| 27.txt | AC | 30 ms | 1280 KiB |
| 28.txt | AC | 36 ms | 2932 KiB |
| 29.txt | AC | 36 ms | 2932 KiB |
| 30.txt | AC | 46 ms | 2932 KiB |
| 31.txt | AC | 4 ms | 256 KiB |
| 32.txt | AC | 18 ms | 1280 KiB |
| 33.txt | AC | 4 ms | 256 KiB |
| 34.txt | AC | 25 ms | 2560 KiB |
| 35.txt | AC | 4 ms | 256 KiB |
| 36.txt | AC | 4 ms | 256 KiB |
| s1.txt | AC | 4 ms | 256 KiB |
| s2.txt | AC | 4 ms | 256 KiB |